After upgrading nuxt I'm getting 404 on .nuxt/fetch.mjs and others
After upgrading Nuxt from 3.13.2 to 3.17.5, some nuxt-generated files cannot be found.
In 3.13.2, the files had names like:
/_nuxt/@id/virtual:nuxt:/var/app/.nuxt/fetch.mjs (with proper slashes)
Now, in 3.17.5, the file names are changed to /_nuxt/@id/virtual:nuxt:%2Fvar%2Fapp%2F.nuxt%2Ffetch.mjs (with %2f instead of slashes), and the files are send to the browser as 404's.
Does anyone know a way to fix this?14 Replies
Hi @Hendrik Jan. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This issue is related to a regression in Nuxt 3.17.x where virtual file paths (like those for fetch.mjs) are being encoded with %2F instead of /, leading to 404 errors when the browser tries to load them. This is caused by a leading slash being added to the virtual file ID, which then gets percent-encoded.
A fix for this regression was implemented in Nuxt 3.17.4, specifically to handle virtual files prefixed with a slash. The fix ensures that these files are resolved correctly and are no longer served as 404s. You can see the relevant change here: fix(nuxt): handle virtual files prefixed with
Upgrade to Nuxt 3.17.4 or newer and clean your build artifacts. This should resolve the 404 errors for virtual files like fetch.mjs caused by the path encoding regression introduced in earlier 3.17.x versions. If the problem persists after upgrading and cleaning, please provide more details about your setup for further troubleshooting. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
/.
How to fix:
- Make sure you are using at least Nuxt 3.17.4 or later (3.17.5 includes this fix).
- If you are still experiencing the issue after upgrading, try clearing your .nuxt and node_modules directories and reinstalling your dependencies.
Upgrade command:
This will ensure all dependencies are up to date and deduplicated, which is recommended after upgrading Nuxt versions v3.17.5 release notes.
Summary:Upgrade to Nuxt 3.17.4 or newer and clean your build artifacts. This should resolve the 404 errors for virtual files like fetch.mjs caused by the path encoding regression introduced in earlier 3.17.x versions. If the problem persists after upgrading and cleaning, please provide more details about your setup for further troubleshooting. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@350171369629286420> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai I tried your suggestion by using your command (
npx nuxi@latest upgrade --dedupe). Also tried npx nuxt upgrade as suggested in the upgrade documentation. I also remove /node_modules and /.nuxt before doing this.
The problem still remains.
Also, it is not only the leading slashes, but all slashes being encoded where they should not, so this fix would not work anyway.Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for your detailed follow-up. Based on the knowledge sources provided, there is acknowledgment of issues related to virtual file paths and encoding changes in recent Nuxt versions. Specifically:
- There was a regression where virtual file paths prefixed with a slash were not handled correctly, and a fix was introduced in 3.17.4 to address leading slashes in virtual file IDs fix(nuxt): handle virtual files prefixed with
I'm sorry, but the knowledge sources do not contain enough information to provide a definitive solution for the issue where all slashes in virtual file paths are being percent-encoded, resulting in 404 errors after upgrading to Nuxt 3.17.5. The fixes mentioned address only specific cases (like leading slashes), not the full encoding of all slashes. You may want to open a new issue on the Nuxt GitHub repository with your findings, as this may be a regression or an unaddressed bug. If you have any more details or logs, sharing them with the Nuxt team could help in diagnosing and resolving the problem. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
/.
- However, your issue is that all slashes are being percent-encoded (e.g., / to %2F) in the virtual file paths, not just the leading slash. The knowledge sources do not provide explicit information about a fix for this specific behavior where all slashes are encoded, resulting in 404s for files like fetch.mjs.
There are also references to changes in how Nuxt handles virtual file system (VFS) paths and encoding, but none of the sources confirm a fix for the issue where all slashes are encoded in the URLs for virtual files refactor(nuxt,schema,vite,webpack): use unplugin for vfs, fix(nuxt): allow url-specific chars in vfs.
Summary:I'm sorry, but the knowledge sources do not contain enough information to provide a definitive solution for the issue where all slashes in virtual file paths are being percent-encoded, resulting in 404 errors after upgrading to Nuxt 3.17.5. The fixes mentioned address only specific cases (like leading slashes), not the full encoding of all slashes. You may want to open a new issue on the Nuxt GitHub repository with your findings, as this may be a regression or an unaddressed bug. If you have any more details or logs, sharing them with the Nuxt team could help in diagnosing and resolving the problem. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@350171369629286420> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai Do you know from which version on problems with encoding were encountered?
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the knowledge sources, issues with encoding of virtual file paths (such as slashes being percent-encoded) were reported and discussed around Nuxt version 3.17.x. Specifically, regressions related to virtual file path handling and encoding changes are mentioned in the context of 3.17.4 and 3.17.5, with fixes for some related issues being merged in these versions fix(nuxt): handle virtual files prefixed with
/.
However, the knowledge sources do not explicitly state the exact version where the encoding problems first appeared. They do indicate that these issues were not present in earlier versions like 3.13.2, and started to be noticed after upgrading to 3.17.x.
I'm sorry, but there's no precise information in the knowledge sources about the first version where the encoding problems began. The available information only confirms that the issue was present in the 3.17.x series.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@350171369629286420> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Okay, I don't know what the problem is yet, but it seems unrelated.
Even version v3.13.2 stops working after deleting package-lock.json and rerunning
npm install.
@kapa.ai
So far I was able to upgrade tiny step by tiny step to Nuxt 3.15.1
Upgrading to 3.15.2 causes the described problem.
Is there a specific change in 3.15.2 that might cause this?Let me check the knowledge base for you again. One moment! :books:
----------------------
Yes, there is a relevant change in Nuxt 3.15.2 that could be related to your encoding issue. In the 3.15.2 changelog, the following fix is listed:
- nuxt: Allow url-specific chars in vfs (#30584)
- nuxt: Decode id before resolving relative imports (#30599)
These changes specifically mention handling URL-specific characters in the virtual file system (VFS) and decoding IDs before resolving imports. This suggests that the way Nuxt encodes and decodes virtual file paths was modified in 3.15.2, which could explain why you started encountering encoding issues after upgrading from 3.15.1 to 3.15.2.
If your problem is related to how slashes or other characters are encoded in virtual file paths, these changes are the most likely cause introduced in 3.15.2 (v3.15.2 changelog).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@350171369629286420> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai and other readers who encounter this same problem.
I finally fixed this issue by adding this to my Apache config:
Let me check the knowledge base for you again. One moment! :books:
----------------------
I'm sorry, but the knowledge sources provided do not contain any information about using the Apache directive
AllowEncodedSlashes NoDecode as a fix for Nuxt virtual file encoding issues, nor do they reference Nuxt issue #30811 or similar Apache configuration solutions.
Therefore, I cannot confirm or elaborate on this solution based on the available knowledge sources. If you need official guidance or confirmation, I recommend checking the Nuxt documentation or the referenced GitHub issue directly, as the knowledge sources here do not cover this specific fix.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@350171369629286420> Kapa.ai is still learning and improving, please let me know how I did by reacting below.