Baroshem / nuxt-security

🛡 Automatically configure your app to follow OWASP security patterns and principles by using HTTP Headers and Middleware
https://nuxt-security.vercel.app/
MIT License
743 stars 56 forks source link

"This module cannot be imported in server runtime" error on fresh Nuxt install #348

Closed alkstal closed 5 months ago

alkstal commented 5 months ago

Version

nuxt-security: 1.0.0 nuxt: 3.9.3

Reproduction Link

https://github.com/johanalkstal/nuxt-security-repro

Steps to reproduce

Run pnpm install Run pnpm run dev

What is Expected?

No errors

What is actually happening?

Nuxt 3.9.3 with Nitro 2.8.1                                                                                 3:41:14 PM
                                                                                                            3:41:14 PM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Alt + D in the browser (v1.0.8)                                                 3:41:15 PM

ℹ Vite server warmed up in 870ms                                                                           3:41:17 PM
ℹ Vite client warmed up in 1043ms                                                                          3:41:17 PM

[3:41:17 PM]  ERROR  This module cannot be importedin server runtime. [importing @nuxt/kit from node_modules/.pnpm/nuxt-security@1.0.0/node_modules/nuxt-security/dist/runtime/nitro/plugins/05-cspSsgPresets.mjs]
vejja commented 5 months ago

@Baroshem This is the same issue with importing @nuxt/kit in the nitro plugin @pi0 has now implemented guards against this in Nuxt 3.9.3 Maybe we need to temporarily disable 05-cpsSsgPresets while we look for an alternative ?

Baroshem commented 5 months ago

Hey @vejja

Yes, it is related to that.

Could you create a fix for that? I will publish a patch version later today that we will fix with 1.1.0

nicokempe commented 5 months ago

Thank you for your quick action 🙏🏽

Baroshem commented 5 months ago

Released a 1.0.1 version where this issue should not appear anymore.

Could you please check if it is gone right now?

image
ethikz commented 5 months ago

@Baroshem It is gone for me now. Thank you @vejja @Baroshem