@standardagents/builder 0.18.2 → 0.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +12 -5
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -19824,15 +19824,22 @@ function addCorsHeaders(response) {
|
|
|
19824
19824
|
return response;
|
|
19825
19825
|
}
|
|
19826
19826
|
|
|
19827
|
-
//
|
|
19828
|
-
|
|
19829
|
-
if (response.headers.has("Set-Cookie")) {
|
|
19827
|
+
// Skip if already has CORS headers
|
|
19828
|
+
if (response.headers.has("Access-Control-Allow-Origin")) {
|
|
19830
19829
|
return response;
|
|
19831
19830
|
}
|
|
19832
19831
|
|
|
19833
|
-
//
|
|
19834
|
-
|
|
19832
|
+
// Prefer mutating the original Response headers. Rebuilding a Response from
|
|
19833
|
+
// response.headers can drop special headers such as Set-Cookie in Worker
|
|
19834
|
+
// runtimes, even when the header is not visible through Headers.has().
|
|
19835
|
+
try {
|
|
19836
|
+
for (const [key, value] of Object.entries(CORS_HEADERS)) {
|
|
19837
|
+
response.headers.set(key, value);
|
|
19838
|
+
}
|
|
19835
19839
|
return response;
|
|
19840
|
+
} catch {
|
|
19841
|
+
// Some Responses, especially fetched upstream responses, have immutable
|
|
19842
|
+
// headers. Fall back to wrapping those responses.
|
|
19836
19843
|
}
|
|
19837
19844
|
|
|
19838
19845
|
// Create new headers with CORS added
|