Simple cors

This commit is contained in:
Imbus 2023-11-28 04:20:00 +01:00
parent d0b50a3a37
commit 67b915d722
3 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,4 @@
use actix_cors::Cors;
use actix_files::Files;
use actix_web::middleware;
use actix_web::web::Data;
@ -34,7 +35,13 @@ async fn main() -> std::io::Result<()> {
info!("Spinning up server on http://localhost:8080");
HttpServer::new(move || {
let cors = Cors::default()
.allowed_origin("https://shitpost.se")
.allowed_methods(vec!["GET", "POST"])
.max_age(3600);
App::new()
.wrap(cors)
.wrap(middleware::Compress::default())
.wrap(middleware::Logger::default())
.wrap(middleware::NormalizePath::trim())