amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.63k stars 236 forks source link

Domain based localed can not working on next 15+ #1572

Closed tianyingchun closed 3 days ago

tianyingchun commented 3 days ago

Description

import { createNavigation } from 'next-intl/navigation';
import { defineRouting } from 'next-intl/routing';
import { LanguageCode } from '@/generated-types';

export const routing = defineRouting({
  // A list of all locales that are supported
  locales: [LanguageCode.en, LanguageCode.de],
  // Used when no locale matches
  defaultLocale: LanguageCode.en,
  localePrefix: 'as-needed',
  localeDetection: false,
  domains: [
    {
      domain: 'www.issilo.com',
      defaultLocale: LanguageCode.en,
      locales: [LanguageCode.en],
    },
    {
      domain: 'www.issilo.de',
      defaultLocale: LanguageCode.de,
    },
  ],
});

the domain based localed always return en

if we use prefix locale (/en,/de) it works www.issilo.com ==> en www.issilo.de ===> en (wrong)

Verifications

Mandatory reproduction URL

https://github.com/tianyingchun/next-intl-issue

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Click on …
  3. See error: …

Expected behaviour

domain based works correct

github-actions[bot] commented 3 days ago

Thank you for your report!

Unfortunately, the reproduction is missing or incomplete, and as such we cannot investigate this issue. Please add a reproduction to the issue, otherwise it will be closed automatically.

Templates:

Creating a good reproduction takes time.

To help us resolve the issue quickly, please simplify the reproduction as much as possible by removing any unnecessary code, files, and dependencies that are not directly related to the problem. The easier it is for us to see the issue, the faster we can help you.

Apart from the reproduction, make sure to include the precise steps on how to reproduce the issue, e.g.:

  1. Open reproduction
  2. Click on …
  3. See error: …

Thank you for your understanding!

FAQ **"I've included a reproduction, what is missing?"** This comment might have been added because your reproduction doesn't point to a destination where the issue can be reproduced. Please make sure that the latest changes were saved in the reproduction and that the link is correct.
tianyingchun commented 3 days ago

yes, i will attach reproduce repo.

tianyingchun commented 3 days ago

https://github.com/tianyingchun/next-intl-issue

tianyingchun commented 3 days ago

BTW: we have multiple domain points one next server port: 3000,

tianyingchun commented 3 days ago
  [ 'x-forwarded-for', '127.0.0.1' ],
  [ 'x-forwarded-host', 'www.issilo.de:443' ],
  [ 'x-forwarded-port', '4001' ],
  [ 'x-forwarded-proto', 'http' ],
  [ 'x-forwarded-server', 'www.issilo.de' ],
  [ 'x-nginx-proxy', 'true' ],
  [ 'x-real-ip', '127.0.0.1' ]

nginx proxy forward, it caused for port 443? i used https

tianyingchun commented 3 days ago

i found i need to config domains with. below it works

export const routing = defineRouting({
  // A list of all locales that are supported
  locales: [LanguageCode.en, LanguageCode.de],
  // Used when no locale matches
  defaultLocale: LanguageCode.en,
  localePrefix: 'never',
  localeDetection: true,
  domains: [
    {
      domain: 'www.issilo.com:443',
      defaultLocale: LanguageCode.en,
      locales: [LanguageCode.en],
    },
    {
      domain: 'www.issilo.de:443',
      defaultLocale: LanguageCode.de,
      // If there are no `locales` specified on a domain,
      // all available locales will be supported here
    },
  ],
});

domain with port 443? it this a issue?

tianyingchun commented 3 days ago

i have changed nignx proxy to remove port , works fine, thanks