Skip to content
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

Enforcing middleware config.matcher to start with '/' and basePath to not end with '/' makes it impossible to handle the index page in middleware #77385

Open
laishere opened this issue Mar 21, 2025 · 1 comment
Labels
Middleware Related to Next.js Middleware.

Comments

@laishere
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/vigorous-maria-t7s3qz?workspaceId=ws_AWWZp8c7McmrRVKgiL4pAk

To Reproduce

Middleware will print the request path in the console.
Base path is set to /test

  1. Run dev
  2. Access /test or /test/, no request shown in the console
  3. Access /test/abc, request path is shown in the console

Current vs. Expected behavior

When accessing /test:
current: the request is not handled by the middleware.
expected: the request should be handled by the middleware.

And I cannot include [""] in the matcher, which will shutdown the server at once.

Provide environment information

Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4242
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.3.0-canary.17 // Latest available version is detected (15.3.0-canary.17).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

@github-actions github-actions bot added the Middleware Related to Next.js Middleware. label Mar 21, 2025
@Netail
Copy link
Contributor

Netail commented Mar 22, 2025

Related; #73786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Middleware Related to Next.js Middleware.
Projects
None yet
Development

No branches or pull requests

2 participants