-
Notifications
You must be signed in to change notification settings - Fork 31
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
404 req when deployed on Vercel #77
Comments
We have noticed a similar issue, or likely the same issue. For us it can be reproduced in any production build. With some static pages, client side navigation will result in a failed
I'm not fully certain where the HEAD request is fired from or why, but I suspect that it has to do with Nextjs' router trying to sniff some details about the page we are navigating into. We are using next version 13.2.4. The Here's an example from our
If I configure the application to support Curiously while
fails, the following example does not fail:
|
@Viktor-as @Jokinen I'm facing the same issue as you're describing when deploying to Vercel. By any chance, did you guys manage to solve this? |
Hey @NSpehler , well I found some workaround for this. In src/pages/_app.tsx I have this code: const App = ({ Component, pageProps }: AppProps) => {
if (typeof window === 'object') {
const { fetch: originalFetch } = window;
const nextDataRequestRegex =
/\/_next\/data\/[^/]+\/[^/]+\/([^/]+)(?!\.json)\/?/;
window.fetch = async (...args) => {
const [url] = args;
const match = url.toString().match(nextDataRequestRegex);
if (match) {
const word = match[1];
const cleanedWord = word.replace(/\.json$/, '');
if (excludeArray.includes(cleanedWord)) {
return Promise.reject();
}
}
return originalFetch(...args);
};
}
return ( ... this intercepts and prevents those unnecessary fetches. so when the fetch matches my words (page translations) in excludeArray the fetch is rejected |
Would any of you test with |
@cvolant that version gives an error. I tried 0-2 and 0-3. App crashes on load. |
Yes, I also saw that 1.11.0-0 crashes in some configs. That is why I tried with different solutions up to 1.11.0-3, but still no luck. I will tell you as soon as I get a working version. I hope I will find some time to work on this soon. |
As commented in another issue, I released 1.11.0-5 to fix the issue. I hope it works now, but I had to drop the support old next versions (<13.5.0)... |
The issue happens to me on 1.11.0-5 and next 14.2.3 on Vercel on server side generated pages when I navigate to them via next/router. Directly accessing it works fine. Also static pages work fine. |
hi,
I am using Next JS 13.4.7 with old Pages directory for routing. Also using next-translate-routes for URL translation which works great locally. But when I upload to vercel and I am visiting pages I see 404 in console and in network tab.
The pages are still getting all data and showing correctly, just that when next is fetching data from cache it fetches 2 times:
This is the same page only the first time it fetches with the same route name as it is declared in pages folder - "contacts" it gets status OK 304.
And the second time it fetches looking for the translated version - "kontaktai.json" and it gets status 404.
Locally I noticed that next is also fetching both of them "contacts.json" and "kontaktai.json" and both times it gets status code OK 304.
But why is it not working when deployed? Any ideas?
The text was updated successfully, but these errors were encountered: