From 46f89c9591337f7f916bb2f865207fb41d134b0b Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:38:15 -0700 Subject: [PATCH] Cherry pick PR #3943: Disable CORS preflight request upon command line flag (#3946) Refer to the original PR: https://github.com/youtube/cobalt/pull/3943 b/27175039 Co-authored-by: johnx --- 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 980f4d971f1bf..f7faf18d91c3f 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;