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

Middlware with basePath on next.config.js is not called on client navigation #39428

Closed
1 task done
nkzawa opened this issue Aug 9, 2022 · 2 comments · Fixed by #39257
Closed
1 task done

Middlware with basePath on next.config.js is not called on client navigation #39428

nkzawa opened this issue Aug 9, 2022 · 2 comments · Fixed by #39257
Assignees
Labels
bug Issue was opened via the bug report template.

Comments

@nkzawa
Copy link
Contributor

nkzawa commented Aug 9, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
Binaries:
  Node: 16.14.0
  npm: 8.12.0
  Yarn: 1.22.17
  pnpm: 7.5.2
Relevant packages:
  next: 12.2.5-canary.0
  eslint-config-next: 12.2.5-canary.0
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When you have bathPath on next.config.js and middleware with matcher, middleware is not called on client navigation.

Expected Behavior

middleware is called

Link to reproduction

https://github.com/nkzawa/next.js-middleware-basepath-bug

To Reproduce

  • run the app with next dev:
  • go to http://localhost:3000/base
  • click link
  • it navigates to /base/hello since middleware is not called
  • reload the page on /base/hello
  • it goes to /base/redirected since middleware is called
@nkzawa nkzawa added the bug Issue was opened via the bug report template. label Aug 9, 2022
@nkzawa nkzawa self-assigned this Aug 9, 2022
@nkzawa
Copy link
Contributor Author

nkzawa commented Aug 11, 2022

This will be fixed on the PR #39257 at the same time

ijjk added a commit that referenced this issue Aug 31, 2022
…39257)

## Feature

As the title, support `has` match, `local`  that works the same with the `rewrites` and `redirects` of next.config.js on middleware config. With this PR, you can write the config like the following:

```js
export const config = {
  matcher: [
    "/foo",
    { source: "/bar" },
    {
      source: "/baz",
      has: [
        {
          type: 'header',
          key: 'x-my-header',
          value: 'my-value',
        }
      ]
    },
    {
      source: "/en/asdf",
      locale: false,
     },
  ]
}
```

Also, fixes #39428

related https://github.com/vercel/edge-functions/issues/178, https://github.com/vercel/edge-functions/issues/179

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant