1

I have added the app next-i18next for internationalisation. After that, all pages in vercel become 404 pages.

By the way, it works perfectly in locally.

WHY??

const { i18n } = require("./next-i18next.config");

module.exports = {
  i18n: {
    locales: ["en", "fr", "nl-NL", "nl-BE", "de", "ja"],
    defaultLocale: "ja",

https://skripts.vercel.app/

Above is the URL of my site. There is a this error in the log.

Failed to load resource: the server responded with a status of 500 ()
Ryosuke Hujisawa
  • 2,682
  • 1
  • 17
  • 18

2 Answers2

-1

Maybe you need to add "getStaticProps" to Dynamic Routing Pages?

// pages/blog/[slug].js
export const getStaticPaths = ({ locales }) => {
  return {
    paths: [
      // if no `locale` is provided only the defaultLocale will be generated
      { params: { slug: 'post-1' }, locale: 'en-US' },
      { params: { slug: 'post-1' }, locale: 'fr' },
    ],
    fallback: true,
  }
}

This described here: https://nextjs.org/docs/advanced-features/i18n-routing#dynamic-routes-and-getstaticprops-pages

I have React + Next.js + next-i18next + Vercel application. And when I deployed to the Vercel I start getting an errors in console:

Internal Server Error 500 with all *.json files.

I just added "locale" keys->values and this is solve my problem.

-1

SOLVED

Please read https://github.com/i18next/next-i18next#vercel-and-netlify this will solve all the problemas

const path = require('path');

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'es'...],
  },
  ...(typeof window === undefined
    ? { localePath: path.resolve('./public/locales') }
    : {}),
};

code by @stophecom

It happened to me and the only solution that I found is to generate all the pages (4000), almost 20 minutes to do a deploy :(

const getStaticPaths = async () => {
  const res = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/xxx`);
  const projects = await res.json();
  const slugs = projects.map((p) => slugifyForFront(p.slug));
  const { locales } = i18n;
  const paths = slugs.flatMap((slug) =>
    locales.map((locale) => ({
      params: { slug },
      locale: locale,
    }))
  );
  return { paths, fallback: false };
};

Probably is not the best solution but I could not make it work using fallback: true | blocking always 404

I hope some one post a better solution

Sfblaauw
  • 1,556
  • 18
  • 21