Disallowed localhost cors in debug mode

This commit is contained in:
Imbus 2023-12-22 22:01:32 +01:00
parent b34a06387f
commit 07b40105c2

View file

@ -39,10 +39,13 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(move || { HttpServer::new(move || {
let cors = Cors::default() let cors = Cors::default()
.allowed_origin("https://shitpost.se") .allowed_origin("https://shitpost.se")
.allowed_origin("http://localhost:8080")
.allowed_methods(vec!["GET", "POST"]) .allowed_methods(vec!["GET", "POST"])
.max_age(3600); .max_age(3600);
// In debug mode, allow localhost
#[cfg(debug_assertions)]
let cors = cors.allowed_origin("http://localhost:8080");
App::new() App::new()
.wrap(cors) .wrap(cors)
.wrap(middleware::Compress::default()) .wrap(middleware::Compress::default())