From b345cb4a77f834f719c9e8d13915aab757884531 Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 27 Oct 2022 15:48:54 +0000 Subject: [PATCH] Allow GET requests from any origin --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 85df00a..4bc2d18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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()