Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Don’t use a locale prefix for the default locale [domain]/test not working #1770

Closed
3 tasks done
xucongyong opened this issue Mar 9, 2025 · 4 comments
Closed
3 tasks done
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@xucongyong
Copy link

Description

https://www.xxx.com/test not working。
https://www.xxx.com/zh/test is working。

error:
404This page could not be found.

routing.ts:

export const routing = defineRouting({
  // ...
  localePrefix: 'as-needed'
});

Verifications

Mandatory reproduction URL

https://www.xucongyong.com/test

Reproduction description

x

Expected behaviour

x

@xucongyong xucongyong added bug Something isn't working unconfirmed Needs triage. labels Mar 9, 2025
@jmisilo
Copy link

jmisilo commented Mar 9, 2025

there might be something wrong, as middleware and actual getRequestConfig return message object.

Image

@xucongyong
Copy link
Author

xucongyong commented Mar 10, 2025

there might be something wrong, as middleware and actual getRequestConfig return message object.

Image

@jmisilo
this is my website?

getRequestConfig is default config. not change

import {getRequestConfig} from 'next-intl/server';
import {routing} from './routing';
 
export default getRequestConfig(async ({requestLocale}) => {
  // This typically corresponds to the `[locale]` segment
  let locale = await requestLocale;
 
  // Ensure that a valid locale is used
  // eslint-disable-next-line
  if (!locale || !routing.locales.includes(locale as any)) {
    locale = routing.defaultLocale;
  }
 
  return {
    locale,
    messages: (await import(`@/messages/${locale}.json`)).default
  };
});

@jmisilo
Copy link

jmisilo commented Mar 11, 2025

there might be something wrong, as middleware and actual getRequestConfig return message object.
Image

@jmisilo this is my website?

getRequestConfig is default config. not change

import {getRequestConfig} from 'next-intl/server';
import {routing} from './routing';

export default getRequestConfig(async ({requestLocale}) => {
// This typically corresponds to the [locale] segment
let locale = await requestLocale;

// Ensure that a valid locale is used
// eslint-disable-next-line
if (!locale || !routing.locales.includes(locale as any)) {
locale = routing.defaultLocale;
}

return {
locale,
messages: (await import(@/messages/${locale}.json)).default
};
});

no, it was in my project, during development. unrelated

@amannn
Copy link
Owner

amannn commented Mar 11, 2025

You already created an issue for this previously at #1756 and have in both cases not bothered to provide a reproduction, despite the bug report template explicitly stating that this is mandatory.

I'll move this to a discussion since it's a usage question, but it's hard for anybody to help you without a reproduction.

If you can come up with a reproduction, add it to the discussion, maybe someone is willing to help.

Repository owner locked and limited conversation to collaborators Mar 11, 2025
@amannn amannn converted this issue into discussion #1777 Mar 11, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

3 participants