diff --git a/change/react-native-windows-4090a69c-674e-42d3-a643-39ec206c7c00.json b/change/react-native-windows-4090a69c-674e-42d3-a643-39ec206c7c00.json new file mode 100644 index 00000000000..1fed4496d44 --- /dev/null +++ b/change/react-native-windows-4090a69c-674e-42d3-a643-39ec206c7c00.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Set Origin HTTP header during CORS (#10700)", + "packageName": "react-native-windows", + "email": "julio.rocha@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp b/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp index 460b5d00f0f..15d23ec1b5b 100644 --- a/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp +++ b/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp @@ -754,6 +754,11 @@ ResponseOperation OriginPolicyHttpFilter::SendRequestAsync(HttpRequestMessage co ValidatePreflightResponse(coRequest, preflightResponse); } + if (originPolicy == OriginPolicy::SimpleCrossOriginResourceSharing || + originPolicy == OriginPolicy::CrossOriginResourceSharing) { + coRequest.Headers().Insert(L"Origin", s_origin.AbsoluteCanonicalUri()); + } + auto response = co_await m_innerFilter.SendRequestAsync(coRequest); ValidateResponse(response, originPolicy);