summaryrefslogtreecommitdiff
path: root/server/src/main.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-07-17 23:42:55 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-07-17 23:44:11 +0200
commitbef3da2a567e3804e12355d9c3d5c09439dbe2ea (patch)
treeab7974c941bd31994da46150234976b33c2f61b5 /server/src/main.rs
parent145be2b3c92e254904d4040850e3c1e9b6a66f32 (diff)
Humble beginnings
Redirect to login if not logged in, on login session cookie is set and projects or reviews are listed.
Diffstat (limited to 'server/src/main.rs')
-rw-r--r--server/src/main.rs11
1 files changed, 11 insertions, 0 deletions
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<Build>) -> fairing::Result {
fn rocket_from_config(figment: Figment) -> Rocket<Build> {
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<Build> {
translation_reviews,
],
)
+ .attach(cors)
.attach(auth::stage(basepath))
.attach(git_root::stage())
.attach(authorized_keys::stage())