Allow cross-origin requests from localhost in production environment
https://codeberg.org/silverpill/mitra/issues/5
This commit is contained in:
parent
0a8fbdafba
commit
a63da82b85
1 changed files with 5 additions and 1 deletions
|
@ -60,7 +60,11 @@ async fn main() -> std::io::Result<()> {
|
||||||
},
|
},
|
||||||
Environment::Production => {
|
Environment::Production => {
|
||||||
let allowed_origin = config.instance_url();
|
let allowed_origin = config.instance_url();
|
||||||
Cors::default().allowed_origin(&allowed_origin)
|
Cors::default()
|
||||||
|
.allowed_origin(&allowed_origin)
|
||||||
|
.allowed_origin_fn(|origin, _req_head| {
|
||||||
|
origin.as_bytes().starts_with(b"http://localhost:")
|
||||||
|
})
|
||||||
.allow_any_method()
|
.allow_any_method()
|
||||||
.allow_any_header()
|
.allow_any_header()
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue