@standardagents/builder 0.18.1 → 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/plugin.js CHANGED
@@ -7338,6 +7338,19 @@ function addCorsHeaders(response) {
7338
7338
  return response;
7339
7339
  }
7340
7340
 
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
+ }
7348
+ return response;
7349
+ } catch {
7350
+ // Some Responses, especially fetched upstream responses, have immutable
7351
+ // headers. Fall back to wrapping those responses.
7352
+ }
7353
+
7341
7354
  // Create new headers with CORS added
7342
7355
  const newHeaders = new Headers(response.headers);
7343
7356
  for (const [key, value] of Object.entries(CORS_HEADERS)) {