-
Notifications
You must be signed in to change notification settings - Fork 60
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
[Feature Request]: expose generated security headers at build time #386
Comments
Hey @mtdvlpr Could you explain why the 1.1.0 version with the runtime does not work? |
Hey @mtdvlpr any feedback from your side? :) |
Hi @Baroshem, as the name suggests, it only works for runtime, not buildtime. When I'm generating static output, the runtime hook is never called. |
Apologies, I missed that @vejja do you maybe have some ifeas on how this can be delivered? |
Hi all |
@vejja awesome! Thanks so much! |
Hey @mtdvlpr How do you view this hook working ? I suppose you want to run |
Indeed. I want to get the headers during the nuxi generate process so that I can create my nginx config file with the proper headers, but if the nitro preset feature is restored, I can revert back to using that, so for me the problem would be fixed. |
Where would you write the code that creates the Nginx conf file in your Nuxt application, would that be in a Nitro plugin ? |
@vejja, I have a Nitro plugin that reads the headers from the routeRules and writes them to a file using |
@mtdvlpr @Baroshem - I am adding the hook functionality to the PR, on top of the nitro preset feature. I'm adding it by way of a Nuxt build time hook, rather than a Nitro run time hook. |
That is a great idea @vejja Thanks! Let's plan it for the 2.0.0-rc.1 release :) |
Is your feature request related to a problem? Please describe.
I use SSG and I want to be able to extract the generated security headers (especially the csp with defined integrity hashes), so that I can write those headers to an nginx configuration file before deploying the static build output to my nginx server.
Describe the solution you'd like
I'm not sure how this feature can be implemented best, but here are some vague ideas I have:
Describe alternatives you've considered
I tried to use the runtime hooks feature introduced in v1.1.0, but this didn't work.
Another solution for me would be to calculate the integrity hashes myself in some script and then use those values to create my header configuration, but it makes more sense to use this module, because it also forces the header values in dev mode, so they can be tested and it gives some common sense defaults that I wouldn't have to configure manually.
Additional context
Related to #336.
The text was updated successfully, but these errors were encountered: