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

Headers specified in next.config.js not being included in response #360

Open
cammanderson opened this issue Aug 30, 2022 · 1 comment
Open
Labels
duplicate This issue or pull request already exists

Comments

@cammanderson
Copy link

Hi!

We have configured headers (such as "Content-Security-Policy") on to our paths, and noticed that they are not being included in Cloudfront responses.

In our use-case we have a public website component and an app, as well as a need for certain paths to have differing policies. The specific headers are those documented on NextJS site.

From what I can ascertain, my options are:

  • Add via a meta tag
  • Create a response header policy (one set of headers for all)

Is this a known limitation or am I missing an input option? I could see another issue raised regarding custom headers, and from what I could understand this is not yet a feature. Would it be difficult adjustment to add some basic support? If not, is there a general direction that can be offered of where to add it in?

Thanks, really appreciate the package.

@ofhouse
Copy link
Member

ofhouse commented Aug 31, 2022

Hey Cameron,

yes this unfortunately a known limitation with the module (See #9).

It happens because our router (that runs as Lambda@Edge) service only runs on origin-request CloudFront event.
The custom headers from the next.config.js need to be added to response, but this event is currently not covered by the router.

A possible solution for adding static headers would be to use the With existing CloudFront template (which allows to modify the CloudFront distribution) and apply a Response Headers Policy to it.

@ofhouse ofhouse added the duplicate This issue or pull request already exists label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants