How to redirect base domain to a locale?
Unanswered
Atlantic cod posted this in #help-forum
Atlantic codOP
I’m trying to implement a simple next.config.mjs redirection from a base domain "/" to the default locale "en_US" but I run into an infinite loop because for some reason, NextJS also tries to redirect /en_US/ back to itself, can someone please help?
https://nextjs.org/docs/app/api-reference/next-config-js/redirects
/** @type {import('next').NextConfig} */
const nextConfig = {
trailingSlash: true,
i18n: {
locales: ['en_US', 'es_US'],
defaultLocale: 'en_US',
},
async redirects() {
return [
{
source: '/',
destination: '/en_US/',
permanent: true,
},
];
},
};
export default nextConfig;
https://nextjs.org/docs/app/api-reference/next-config-js/redirects
/** @type {import('next').NextConfig} */
const nextConfig = {
trailingSlash: true,
i18n: {
locales: ['en_US', 'es_US'],
defaultLocale: 'en_US',
},
async redirects() {
return [
{
source: '/',
destination: '/en_US/',
permanent: true,
},
];
},
};
export default nextConfig;