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

Error when adding a dot to the first segment in url #461

Closed
ninnjak opened this issue Aug 18, 2023 · 1 comment
Closed

Error when adding a dot to the first segment in url #461

ninnjak opened this issue Aug 18, 2023 · 1 comment
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@ninnjak
Copy link

ninnjak commented Aug 18, 2023

Description

I'm facing the same issue outlined here: #307

I have an application that uses the first segment for user profiles e.g. (http://localhost:3000/username) when the username contains a dot (http://localhost:3000/username.username) it attempts to pass username.username as the locale instead of the default locale. It works with all other locales when explicitly set in the url.

Mandatory reproduction URL (CodeSandbox or GitHub repository)

https://codesandbox.io/p/sandbox/inspiring-sun-2fsrpw

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Navigate to /username.username
  3. Returns 404 page

Expected behaviour

The url should be resolved using the default locale

@ninnjak ninnjak added bug Something isn't working unconfirmed Needs triage. labels Aug 18, 2023
@amannn
Copy link
Owner

amannn commented Aug 21, 2023

The reason why you're encountering this issue is that your middleware matcher excludes anything that contains a dot.

You can fix this by adjusting the matcher, but be careful that you're still excluding anything that is not a content route (e.g. favicon.ico, etc.). You could consider adding all static assets to a folder like ./public/assets and then exclude that one from the middleware:

export const config = {
  matcher: ["/((?!api|_next|assets).*)"],
};

Working demo: https://codesandbox.io/p/sandbox/youthful-haibt-xp92kh?file=/middleware.ts:15,1-17,3

I'll move this to a discussion since it's more a usage question than a bug report.

Repository owner locked and limited conversation to collaborators Aug 21, 2023
@amannn amannn converted this issue into discussion #464 Aug 21, 2023

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

2 participants