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

Can not set Headers using {runtimeHooks:true} #373

Closed
stefffens opened this issue Feb 13, 2024 · 2 comments · Fixed by #374
Closed

Can not set Headers using {runtimeHooks:true} #373

stefffens opened this issue Feb 13, 2024 · 2 comments · Fixed by #374
Labels
bug Something isn't working

Comments

@stefffens
Copy link

Version

nuxt-security: 1.1.1
nuxt: 3.10.1

Reproduction Link

https://stackblitz.com/edit/nuxt-starter-urmubt

Steps to reproduce

Set the runtimeHooks like described in the docs

What is Expected?

The settings in the plugin/headers.ts file should be applied

What is actually happening?

They are not applied.

How to solve?

Digging a bit deeper into the output of nuxt it seems like the setHeader (not setHeaders) method is not being created in the output of a nuxt build:
.output/server/chunks/nitro/node-server.mjs file
It seems to originate from the ./src/runtime/nitro/plugins/00-context.ts file in nuxt-security.

The issue is fixed by adding "setHeader" as an explicit import from "#imports"

@stefffens
Copy link
Author

Added a PR to fix the issue

@quarkus
Copy link

quarkus commented Feb 14, 2024

@huang-julien might want to take a look 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants