Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write (deferred) headers #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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