-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Full static mode dynamic pages payload 404 errors (i18n module) #7717
Comments
@atinux here is a information that you've requested: Github: https://github.com/divine/nuxt-payload-error Error: Uncaught SyntaxError: Unexpected token '<' payload.js:1 Normally it's a 404 error but on surge it's unexpected token, quite interesting. Thanks! |
I'm having the same Uncaught SyntaxError: Unexpected token '<'. (404) I noticed that in the generated HTML files, the src of the payload.js and state.js files does not have the router base param concatenated with it (when running inside a domain directory, for example). |
Yeah, I just passed all the dist html files into a shell function that concatenated the router.base and everything seems to work. |
I have seen several of these 404 cases in the static folder, and in my case, the error was: As the build process now happens in 2 steps (build and export), I was injecting the environment variables only in the first process. When the export ran, without the injected variable, it exported the last static things without the variable (in my case, the router.base). In short: my implementation error. If you come by, check if all your environment variables are being injected in the 2 moments. (not all are necessary for export) |
Hi @lucasvst. It seems you have another issue that causes payload not found an error with |
@pi0 In fact, was not an issue. Was an implementation error (my implementation). I was not injecting my variables on export step. I let the comment here for future users check this point before. |
@atinux @pi0 guys it's still broken, could you please reopen this issue? Github: https://github.com/divine/nuxt-payload-error Error: Uncaught SyntaxError: Unexpected token '<' payload.js:1 Quite interesting fact this time on surge reactivity is broken because it can't find commons.297bbcd.js:1 Thanks! |
I've updated with latest version on Github, CS and Surge link is http://careful-money.surge.sh/about/ |
So there is currently no way to use i18n in a full static app ? |
I actually have the same issue without using i18n.
|
I have the same issue than @felixheck, full static website with a link to a dynamic page (37M possible routes so no pre-rendering possible). My NuxtLink's redirecting to this dynamic pages have the |
having the same issue as @felixheck @nicolasbeauvais, and no-prefetch also doesn't work for me. |
Related #8003 |
Hi there, We are aware of this issue but this one is a bit tricky since we actually need to generate a manifest to know what routes has been statically generated (vs ignored), this manifest can have a huge size based on the number of generated route and also affect performances. This does not mean we cannot solve it but we have to take the right decision about it. |
i am sorry.i can't speak english I have a similar problem. Is there a problem with my WebPack configuration?(default configuration ) Versions
thank you very much for seeing this question. Thanks! |
Hi. How can I prevent those errors to be displayed? We didn't have that error before but we added GTM to the project so we had to update Nuxt version and after that update we came across this issue. If someone has a work around for this issue please post it here! The issue happens as soon as I build a link for a dynamic page. I'll try the no-prefetch feature for the links but it will happen again once I get into the dynamic page.
|
@atinux any update on this? I can understand this might be not a priority but until nuxt 3 release this is really bugging everyone. Thanks! |
I will look at this ASAP |
I found a stable workaround for those of you that use Vercel by leveraging the edge-network caching (Serverless Pre-Rendering), I think it's a good compromise between SSR and static generation that should work for most use cases. Nuxt.js configYou need to deploy your app with a server target, and exclude all pages that you do not want to be statically generated by Nuxt.js (routes that can render thousands of different pages should in most case be excluded): // nuxt.config.js
export default {
target: 'server',
generate: {
exclude: [
/^\/dynamic-route\//,
]
},
} Vercel configNow as we are deploying in server mode, we need to use @nuxtjs/vercel-builder to run our code on Vercel. By using the {
"version": 2,
"builds": [
{
"src": "nuxt.config.js",
"use": "@nuxtjs/vercel-builder",
"config": {
"generateStaticRoutes": true
}
}
],
"headers": [
{
"source": "/(.*)",
"headers" : [
{
"key" : "Cache-Control",
"value" : "s-maxage=43200, stale-while-revalidate"
}
]
}
]
} This solution has a tiny performance cost for the first render of SSR dynamic pages, but the increased flexibility between static and dynamic is totally worth it for me. |
@Sford4 sorry but I don't think that SO is a better place to document it. You'd better writing it here because actual developers of nuxt are here. 😉 |
@divine sounds good, here's the write up: When I run
This successfully creates my dynamic routes, which accept a payload from generation. Each route should have their own headers, from my
During After Navigation in-app works fine, so if I go to a different page and come page to my dynamic route content will appear, so Without Question 1: Any ideas how to get my full static business pages to accept and hold onto their payload? Question 2: My whole goal is to prep my dynamic routes for SEO, so the Again, let me know if I need to raise a new issue, or if there's another forum where I can get help. Thank you so much! |
We're experiencing the same, our payloads which are triggered by nuxt-links just contain the rendered |
Same error using
Since I think that there should be a way to catch these errors for dynamic routes |
@divine Surge rewrites all URLs that don't have a corresponding static file to /200.html. So, the error is different because a request for "payload.js" is returned, but it is not a javascript file that was expected. |
I know, but it's pretty lame to redirect .js files at least. Showing error is important instead of giving plain 200.html content. Anyways let's keep discussion going on actual issue:
Workaround is to use server mode instead of static one. As I remember you were using Firebase so basically there is no resolution. @atinux any updates? Thanks! |
Not a solution, but a simple patch to the issue for me was to create a noop {
"source": "/admin/**/payload.js",
"destination": "/payload.js"
} Back to the solution: My understanding that On my home page, Nuxt prefetches a bunch of Is there a way to disable the prefetch for certain routes? Or maybe make the prefetch smarter by not prefetching the payload if it is known at build time to be empty? |
Same issue, deploying to netlify (unexpected token -> js files containing html index page, I guess server defaults to index instead of not found 404 on netlify). Using PWA it immediately happens on opening of the app when the loading screen is shown. I narrowed it down to: After the new netlify deployment the PWA has the issue again (seems to point to old resources), when I use chrome inspect to clear application cache it works again (until next deployment). Root cause (404 or unexpected '<') Current workaround @divine can you reproduce it following my steps? But what's the real cause for pointing to the old js files? Is it a workbox cache issue? |
@Anima-t3d I think you're missing the point that the error happens on dynamic link routes which were'nt generated initially. Basically your workaround doesn't solve it.
Any update on this @atinux ? |
Working on a workaround :) |
Not sure it's directly related, but when I enable no sniffing of the content type I get a slight variation of the error:
|
Seems like the issue I have is caused by: nuxt-community/pwa-module#381 So although the symptoms are the same the cause seems to be different, just thought to add here for others who end up here. |
* fix(vue-app): handle missing payloads on full static Fixes #7717 * chore: rename routesManifest to manifest * chore: remove console.log * chore(vue-app): don't have staticAssetsBase if undefined * chore: add manifest option * test: update snapshot * chore: use foundRoute to avoid multiple vars name Co-authored-by: Pooya Parsa <pyapar@gmail.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
I've had the same problems with 404 errors for payloads on dynamic pages. These all disappeared when using nuxt@2.14.8. Thank you! |
Can confirm that my problems has also been fixed in v2.14.8 - thanks so much 🙏 |
I had the
|
@jeerbl please create another issue for manifest with a reproduction please |
For me the problem has also been fixed by upgrading to v2.14.8. |
@jeerbl have you gotten any solution for this issue? I am getting this error, my nuxt version 2.15.7 |
Same issue here. |
Hey! Could you show me how did you do that please? |
Versions
Reproduction
Additional Details
When using nuxt-i18n with full static generated mode there are still 404 errors for payload.js on dynamic pages.
Related #7559 #7648 #7622
Steps to reproduce
Check codesandbox.
About page tries to pre-fetch "_nuxt/static/1594718554/fr/test/payload.js" and gets 404 error in console log.
What is Expected?
Payload shouldn't be fetched because it wasn't generated at all.
What is actually happening?
Still 404 errors.
The text was updated successfully, but these errors were encountered: