-
Notifications
You must be signed in to change notification settings - Fork 65
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
implement headers with routeRules
#27
Comments
I will implement the route roules the way you recommended but for cors I will leave it for now as it was quite a recent feature :) Later on I will reconfigure the cors to work similar way |
Hi @Baroshem! I wondering about the possibility to apply the |
Hey @maxdzin It is possible. Take a look at this example file https://github.com/Baroshem/nuxt-security/blob/main/playground/nuxt.config.ts export default defineNuxtConfig({
modules: ['nuxt-security'],
// Per route configuration
routeRules: {
'secret': {
headers: {
'X-XSS-Protection': '1' // Here you need to pass 'Content-Security-Policy': 'your values here'
},
},
},
}) |
Hi @Baroshem! OK, thank you! So it seems the headers are supported (I didn't yet check that under the hood). Then at least its declaration needs to be updated, because there's a TS error:
The route rules don't include
So cannot go further since typecheck error. |
Ah I see. You are correct. Could you please create a new issue with this type bug? If you have some time and would like to contribute, the PR will be more than welcome :) |
@Baroshem Ok, sure. I'll create a PR then. |
It feels like you could implement setting various headers with routeRules - e.g. a default value imposed via:
That way they could also be overridden with other route rules.
Moreover, it would be good to configure
cors
in the same way, and for the same reason. As a heads-up, likely future cors enhancements are anticipated directly within nitro.The text was updated successfully, but these errors were encountered: