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

feat(lambda-at-edge): support custom headers (with caveats) #662

Merged
merged 4 commits into from
Oct 10, 2020

Conversation

dphang
Copy link
Collaborator

@dphang dphang commented Oct 10, 2020

This continues: #587

  • Supports custom headers on pages and API handlers

Caveats: because of the way the default handler is currently architected (using S3 origin + origin response), any path that hits the S3 origin has its request.uri rewritten to the S3 path. This includes SSG pages, SSG data requests, public files, etc. Because of this, to have a custom header on these paths, you will need to specify the S3 key rather than the path. This is different from Next.js.

For example: if you have an SSG page at path /my-page, you will need to specify the S3 key as the header source in next.config.js, which will probably be something like /my-page.html.

Also, you can't add headers to next/static/* or static/* paths, as those do not have origin handlers attached to them.

In the future we may improve/fix this to be more in line with Next.js (e.g by possibly getting rid of the S3 origin and having the origin request handler make requests to S3 directly).

Tests

Added unit and e2e tests.

@dphang dphang merged commit 8b9e822 into master Oct 10, 2020
@delete-merged-branch delete-merged-branch bot deleted the dphang/custom-headers branch October 10, 2020 19:45
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.

None yet

1 participant