nuxt-security: Wrong paths on Windows

Hello, i was trying to import the module inside my project but after importing the module i always seem to be getting the following error. image

This error happens in my own project but also when i setup a completely empty nuxt project with nothing in it.

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  modules: ["nuxt-security"],
});
{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "nuxt": "3.0.0-rc.12"
  },
  "dependencies": {
    "nuxt-security": "^0.5.0"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 34 (22 by maintainers)

Most upvoted comments

I believe this is an issue on the nitro side as other handlers are working correctly, only the one that is being pushed to nitro plugins array is failing.

For all users facing the problem. When you set hidePoweredBy to false in your nuxt.config.ts your project will work fine and you can use it as a workaround now until a proper fix will be published. It will disable one of the middlewares (that is not as crucial as other middlewares) and will make your app work corectly on Windows.

CC @maxime-ducoroy @mikeschepers4 @luabraggion

@mikeschepers4 I will release the new version in the upcoming days with this fix and few other smaller functionalities.

Hey folks,

I have tested solution from @pi0 and it seems to be working now. Please test it out in your environment and let me know if there are any issues. Sorry that it tooked so long and hope that you will be still using the module 😃

Can confirm that your workaround is working. thanks 😃

@danielroe @pi0

I managed to test it out on an old Windows laptop and the issue is appearing when I want to push Nitro plugin from module:

https://github.com/Baroshem/nuxt-security/blob/1c93c65bb53eb9607df1c8ab970f79f74d68c13e/src/module.ts#L34

Other URL;s are working correctly. Is it caused by this? https://github.com/nuxt/framework/pull/8626/files

I have updated the package to work with 3.0.0-rc.13 version but the issue is still there

Ive not been able to find a solution. I think it may have something to do with the way nitro is referencing the given paths. ill look further once i have some time again

Ok just tested but im getting the same error message with your suggestion. the path does seem to be correct if i log it however. will look into it a bit deeper

Sorry ran out of time to test it last week. will test today 😃

Ok, so I will replace this for the next version. Thanks for the help!

Yes, exactly. It can be resolved in this project by using pathe instead of path. We can probably also normalise in addServerHandler etc. in kit.