-
Notifications
You must be signed in to change notification settings - Fork 463
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
Building app using strategy: 'prefix'
throws pre-render (Error: [301])
#2256
Comments
Thank you for your reporting! This issue is not with the nuxt i18n module, because you are prerendering the build with the The I saw your nuxt.config.ts and the
|
@kazupon If I'll remove ssr and prerender the entire app will act as an spa. whats the best / right way to use strategy prefix with routeRules? |
Thank you for your use-cases. Your reproduction of the routing strategy uses routeRules: {
'/en': { prerender: true },
'/he': { prerender: true },
'/en/test': { prerender: true },
'/he/test': { prerender: true },
}, |
You can specifically set your root to not prerender.
|
And its fine to not have a root |
@kazupon and btw, any reason why other strategies totally ignores the only strategy that respects the Any suggestions? |
@Dananz I am using |
Can some expert verify this gentleman's statement? seems correct to me. |
disclaimeri am not planning on running this i18n: {
lazy: true,
langDir: "locales/",
defaultLocale: "en",
strategy: "prefix",
detectBrowserLanguage: {
useCookie: true,
cookieKey: "i18n_redirected",
fallbackLocale: "en",
redirectOn: "root",
},
customRoutes: "config",
pages: {
about: {
de: "/ueber-mich",
en: "/about",
},
},
locales: [
{
name: "Deutsch",
code: "de",
iso: "de-DE",
file: "de",
icon: "i-circle-flags-de",
},
{
name: "English",
code: "en",
iso: "en-US",
file: "en",
icon: "i-circle-flags-en",
},
],
},
running Prerendering 7 initial routes with crawler
├─ /200.html (37ms)
├─ /404.html (38ms)
├─ / (108ms)
│ └── Error: [404] Page not found: /
├─ /en (103ms)
├─ /en/about (83ms)
├─ /de (104ms)
├─ /de/ueber-mich (104ms)
├─ /en/about/_payload.json (0ms)
├─ /en/_payload.json (1ms)
├─ /de/_payload.json (3ms)
├─ /de/ueber-mich/_payload.json (1ms)
Errors prerendering:
├─ / (108ms)
│ └── Error: [404] Page not found: /
ERROR Exiting due to prerender errors. |
I need to use generate and have the same problem. In my case i switched to prefix because of SEO Issues. |
@Sazzels I'm facing the same issue for the default route. In my case I "fixed" it by adding a rootRedirect to the i18n options:
But this also throws a warning when running |
This issue should be (at least partially) fixed by #2894 which is included in the edge release, I have updated the original reproduction to demonstrate here. Please let me know if any of you still run into this issue when using the edge release, install with |
@BobbieGoede the
import en from '@/i18n/messages/en';
import nl from '@/i18n/messages/nl';
export default defineI18nConfig(() => ({
legacy: false,
locale: 'nl',
locales: [
{
code: 'en',
iso: 'en-US',
},
{
code: 'nl',
iso: 'nl-NL',
},
],
messages: {
en,
nl,
},
})); I would expect the redirect from |
@bnachtweh |
Never mind, it seems that the cookie was set to |
Since the original issue should be resolved I'll close this issue. If anyone is running into issues please open a new issue with a minimal reproduction! |
Environment
Darwin
v16.16.0
3.6.5
2.5.2
npm@8.11.0
vite
-
-
-
Reproduction
https://stackblitz.com/edit/nuxt-starter-jkohmm?file=nuxt.config.ts
Describe the bug
When trying to use
strategy: 'prefix'
, Im getting(Error: [301])
Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: