fix cors error

This commit is contained in:
mpostma 2021-01-12 16:46:53 +01:00
parent fa40c6e3d4
commit 60c636738b
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A
1 changed files with 7 additions and 5 deletions

View File

@ -82,13 +82,15 @@ async fn main() -> Result<(), MainError> {
let enable_frontend = opt.env != "production";
let http_server = HttpServer::new(move || {
create_app(&data, enable_frontend)
.wrap(
Cors::default()
let cors = Cors::default()
.send_wildcard()
.allowed_headers(vec!["content-type", "x-meili-api-key"])
.max_age(86_400) // 24h
)
.allow_any_origin()
.allow_any_method()
.max_age(86_400); // 24h
create_app(&data, enable_frontend)
.wrap(cors)
.wrap(middleware::Logger::default())
.wrap(middleware::Compress::default())
.wrap(NormalizePath)