Allow GET requests from any origin

This commit is contained in:
silverpill 2022-10-27 15:48:54 +00:00
parent 23dca1b4c5
commit b345cb4a77

View file

@ -1,6 +1,7 @@
use actix_cors::Cors;
use actix_web::{
dev::Service,
http::Method,
middleware::Logger as ActixLogger,
web,
App, HttpServer,
@ -93,7 +94,8 @@ async fn main() -> std::io::Result<()> {
};
cors_config
.allowed_origin(&config.instance_url())
.allowed_origin_fn(|origin, _req_head| {
.allowed_origin_fn(|origin, req_head| {
req_head.method == Method::GET ||
origin.as_bytes().starts_with(b"http://localhost:")
})
.allow_any_method()