From bef3da2a567e3804e12355d9c3d5c09439dbe2ea Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 17 Jul 2025 23:42:55 +0200 Subject: Humble beginnings Redirect to login if not logged in, on login session cookie is set and projects or reviews are listed. --- server/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'server/src/main.rs') diff --git a/server/src/main.rs b/server/src/main.rs index 7a6b1b7..9a4f781 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -8,6 +8,7 @@ use rocket::http::Status; use rocket::response::status::{Custom, NotFound}; use rocket::serde::json::Json; use rocket::{futures, Build, Rocket, State}; +use rocket_cors::AllowedOrigins; use rocket_db_pools::{sqlx, Connection, Database}; use sqlx::Acquire; use std::path::PathBuf; @@ -1465,6 +1466,15 @@ async fn run_migrations(rocket: Rocket) -> fairing::Result { fn rocket_from_config(figment: Figment) -> Rocket { let basepath = "/api/v1"; + + let cors = rocket_cors::CorsOptions { + allowed_origins: AllowedOrigins::all(), + allow_credentials: false, + ..Default::default() + } + .to_cors() + .unwrap(); + rocket::custom(figment) .attach(Db::init()) .attach(AdHoc::try_on_ignite("Database Migrations", run_migrations)) @@ -1497,6 +1507,7 @@ fn rocket_from_config(figment: Figment) -> Rocket { translation_reviews, ], ) + .attach(cors) .attach(auth::stage(basepath)) .attach(git_root::stage()) .attach(authorized_keys::stage()) -- cgit v1.2.3-70-g09d2