@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/index.js CHANGED
@@ -19829,6 +19829,19 @@ function addCorsHeaders(response) {
19829
19829
  return response;
19830
19830
  }
19831
19831
 
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
+ }
19839
+ return response;
19840
+ } catch {
19841
+ // Some Responses, especially fetched upstream responses, have immutable
19842
+ // headers. Fall back to wrapping those responses.
19843
+ }
19844
+
19832
19845
  // Create new headers with CORS added
19833
19846
  const newHeaders = new Headers(response.headers);
19834
19847
  for (const [key, value] of Object.entries(CORS_HEADERS)) {