Using next-intl works locally but gives me a 404 when deploying to vercel
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
not sure what im doing wrong, my localization works perfectly locally but once i deploy to vercel i cant render any page, i only get a 404 and i dont automatically get redirected to any locale
i have set up routing.ts as
my next.config.ts is as follows:
navigation.ts is:
request.ts:
and proxy.ts
i have set up routing.ts as
import { defineRouting } from "next-intl/routing";
export const routing = defineRouting({
locales: ["en", "es"],
defaultLocale: "es",
});my next.config.ts is as follows:
import { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
const nextConfig: NextConfig = {
images: {
domains: ["cdn.sanity.io"],
},
};
const withNextIntl = createNextIntlPlugin();
export default withNextIntl(nextConfig);navigation.ts is:
import { createNavigation } from "next-intl/navigation";
import { routing } from "./routing";
export const { Link, redirect, usePathname, useRouter, getPathname } =
createNavigation(routing);request.ts:
import { getRequestConfig } from "next-intl/server";
import { hasLocale } from "next-intl";
import { routing } from "./routing";
export default getRequestConfig(async ({ requestLocale }) => {
// Typically corresponds to the[locale]segment
const requested = await requestLocale;
const locale = hasLocale(routing.locales, requested)
? requested
: routing.defaultLocale;
return {
locale,
messages: (await import(../messages/${locale}.json)).default,
};
});and proxy.ts
import createMiddleware from "next-intl/middleware";
import { routing } from "./i18n/routing";
export default createMiddleware(routing);
export const config = {
// Match all pathnames except for
// - … if they start with/api,/trpc,/_nextor/_vercel// - … the ones containing a dot (e.g.favicon.ico)
matcher: "/((?!api|trpc|_next|_vercel|.*\\..*).*)",
};1 Reply
Asiatic LionOP
the deployment logs looks good too
Route (app)
┌ ○ /
├ ○ /_not-found
├ ● /[locale]
│ ├ /en
│ └ /es
├ ● /[locale]/about
│ ├ /en/about
│ └ /es/about
├ ƒ /[locale]/newsroom
├ ƒ /[locale]/newsroom/[slug]
├ ● /[locale]/regulations
│ ├ /en/regulations
│ └ /es/regulations
└ ● /[locale]/solutions
├ /en/solutions
└ /es/solutions
ƒ Proxy (Middleware)
○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses generateStaticParams)
ƒ (Dynamic) server-rendered on demand
Build Completed in /vercel/output [37s]
Route (app)
┌ ○ /
├ ○ /_not-found
├ ● /[locale]
│ ├ /en
│ └ /es
├ ● /[locale]/about
│ ├ /en/about
│ └ /es/about
├ ƒ /[locale]/newsroom
├ ƒ /[locale]/newsroom/[slug]
├ ● /[locale]/regulations
│ ├ /en/regulations
│ └ /es/regulations
└ ● /[locale]/solutions
├ /en/solutions
└ /es/solutions
ƒ Proxy (Middleware)
○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses generateStaticParams)
ƒ (Dynamic) server-rendered on demand
Build Completed in /vercel/output [37s]