From 731b57d9868472b55746334de646bbc2bae361a6 Mon Sep 17 00:00:00 2001 From: John Xu Date: Tue, 6 Aug 2024 20:13:07 -0700 Subject: [PATCH] Disable CORS preflight request upon command line flag We were still sending preflight request even when cors is disabled by dev flag. b/27175039 Change-Id: Ib8dba31d581c44f77e623742b565ed9396448ea1 --- 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;