From 07b40105c22cedaeca6789ac9ceae188de261d9d Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Fri, 22 Dec 2023 22:01:32 +0100 Subject: [PATCH] Disallowed localhost cors in debug mode --- server/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/main.rs b/server/src/main.rs index d6792e8..b3d0788 100755 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -39,10 +39,13 @@ async fn main() -> std::io::Result<()> { HttpServer::new(move || { let cors = Cors::default() .allowed_origin("https://shitpost.se") - .allowed_origin("http://localhost:8080") .allowed_methods(vec!["GET", "POST"]) .max_age(3600); + // In debug mode, allow localhost + #[cfg(debug_assertions)] + let cors = cors.allowed_origin("http://localhost:8080"); + App::new() .wrap(cors) .wrap(middleware::Compress::default())