Skip to content

Conversation

dbaynard
Copy link

@dbaynard dbaynard commented Nov 9, 2023

Unlike ResponseWriter.Write, io.Copy doesn't add the deferred headers. Deferred headers are applied after the proxied response.

This (not standalong) is CORS configuration, for example, that only works with the change.

header {
  Access-Control-Allow-Origin "{re.origin.0}"
  Access-Control-Allow-Credentials true
  Access-Control-Expose-Headers "{args[1]}"
  Vary Origin
  defer
}

Fixes #65 (though I suppose there may be issues with PUT and DELETE, too).

(Edit: PUT and, probably, DELETE, are affected, too — this can be merged as is, but if I fix PUT and DELETE beforehand I'll add to this PR.)

Unlike `ResponseWriter.Write`, `io.Copy` doesn't add the deferred
headers. Deferred headers are applied _after_ the proxied response.

This (not standalong) is CORS configuration, for example, that only
works with the change.

```Caddyfile
header {
  Access-Control-Allow-Origin "{re.origin.0}"
  Access-Control-Allow-Credentials true
  Access-Control-Expose-Headers "{args[1]}"
  Vary Origin
  defer
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deferred (CORS) headers not propagated
1 participant