From bf3078dd98c91dcfe1f2cc88738204511771d199 Mon Sep 17 00:00:00 2001 From: johnx Date: Thu, 8 Aug 2024 01:34:15 +0800 Subject: [PATCH] Disable CORS preflight request upon command line flag (#3943) b/27175039 (cherry picked from commit d4ec2d6773b182a58af143944035d857d169fe3e) --- cobalt/loader/cors_preflight.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cobalt/loader/cors_preflight.cc b/cobalt/loader/cors_preflight.cc index 46172a83de95..5872cae3383f 100644 --- a/cobalt/loader/cors_preflight.cc +++ b/cobalt/loader/cors_preflight.cc @@ -244,6 +244,9 @@ bool CORSPreflight::IsPreflightNeeded() { if (force_preflight_) { return true; } + if (cors_policy_ == network::kCORSOptional) { + return false; + } // Preflight is not needed if the request method is CORS-safelisted request // method and all headers are CORS-safelisted request-header. std::vector unsafe_headers;