@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/plugin.js
CHANGED
|
@@ -7333,15 +7333,22 @@ function addCorsHeaders(response) {
|
|
|
7333
7333
|
return response;
|
|
7334
7334
|
}
|
|
7335
7335
|
|
|
7336
|
-
//
|
|
7337
|
-
|
|
7338
|
-
if (response.headers.has("Set-Cookie")) {
|
|
7336
|
+
// Skip if already has CORS headers
|
|
7337
|
+
if (response.headers.has("Access-Control-Allow-Origin")) {
|
|
7339
7338
|
return response;
|
|
7340
7339
|
}
|
|
7341
7340
|
|
|
7342
|
-
//
|
|
7343
|
-
|
|
7341
|
+
// Prefer mutating the original Response headers. Rebuilding a Response from
|
|
7342
|
+
// response.headers can drop special headers such as Set-Cookie in Worker
|
|
7343
|
+
// runtimes, even when the header is not visible through Headers.has().
|
|
7344
|
+
try {
|
|
7345
|
+
for (const [key, value] of Object.entries(CORS_HEADERS)) {
|
|
7346
|
+
response.headers.set(key, value);
|
|
7347
|
+
}
|
|
7344
7348
|
return response;
|
|
7349
|
+
} catch {
|
|
7350
|
+
// Some Responses, especially fetched upstream responses, have immutable
|
|
7351
|
+
// headers. Fall back to wrapping those responses.
|
|
7345
7352
|
}
|
|
7346
7353
|
|
|
7347
7354
|
// Create new headers with CORS added
|