-
Notifications
You must be signed in to change notification settings - Fork 56
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
Wrong paths on Windows #42
Comments
Hey @mikeschepers4 Are you using Static Site Generation or SSR? |
This is really strange, I have just tested it out on a same project and it works (the only difference is that I am using yarn I believe) Package.json: {
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"nuxt": "3.0.0-rc.12"
},
"dependencies": {
"nuxt-security": "^0.5.0"
}
} Nuxt.config.ts export default defineNuxtConfig({
modules: ['nuxt-security']
}) |
It seems to happen both in ssr and static site generation. I tried to make a stackblitz but there it doesnt happen. I think it might have something to do with the operating system since my error complained about a bad character sequence. (the error is in my screenshot above). Could windows have something to do with it? |
adding Edit: This seems to work, i can see the CSP headers and other security elements added to my headers. Im pretty sure that anyone using this on windows will get the same errors |
I see, quite strange. I will ask around in the nuxt community. From what you say, this bug can be caused by nuxt itself. |
I would recommend using |
I think the problem lies in this file here the resolve methods dont seem to normalize the paths correctly for windows at least. The output seems to be like this: Whilst you need this output on windows: |
Yes, exactly. It can be resolved in this project by using |
@danielroe so should I update the module itself to use pathe instead of path or will this be something included in the next version of kit? |
You should use |
Ok, so I will replace this for the next version. Thanks for the help! |
@mikeschepers4 I will release the new version in the upcoming days with this fix and few other smaller functionalities. |
Amazing! I'll keep an eye on it. Thanks for the quick response! |
Hey @mikeschepers4 I have released a new version with the fix for that. Could you please check if it works right now? :) |
@Baroshem Just updated the module to check. there still seems to be an issue. I'll look into this a bit deeper. (tested with a newly created nuxt app) |
I see, maybe then changing the path to pathe is not enough. Let me know please after you do some more testing. Unfortunately I do not have a Windows device so I cannot really test it out (almost like blind coding). I can also release a quick patch version to make it work once we find the cause. What if you wrap all the paths to the middlewares with normalize? Or just add this:
|
Or for each middleware replace |
Any news @mikeschepers4 ? 🙂 |
Sorry ran out of time to test it last week. will test today :) |
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 |
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 |
@danielroe Could you take a look at that? Maybe this is an issue in the nitro? |
hey @mikeschepers4 Have you managed to test it out more? |
Sorry no. I think a potential fix would be to make use of relative paths instead of absolute paths. But i dont know how easy that would be to integrate in this solution. Or Nitro needs to make a fix to handle absolute paths correctly on windows machines. I sadly dont have a lot of time at the moment to work that out myself |
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: Line 34 in 1c93c65
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 |
In dev mode this likely needs to be a file URL not a path. Fancy testing that? If so, we can likely fix in Nuxt itself. |
Related to nuxt/nuxt#15249 |
I tested it by sending even a simple path to the plugins array, it still shouts that it is not correct. |
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 |
Can confirm that your workaround is working. thanks :) |
Related to nuxt-modules/html-validator#232 |
Guys, Daniel is already working on fixing this issue on the nitro side. I will make sure to update nuxt to a newer version once it is released. For now, make sure to use this workaround -> #42 (comment) |
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 :) |
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.
This error happens in my own project but also when i setup a completely empty nuxt project with nothing in it.
The text was updated successfully, but these errors were encountered: