Commit graph

10 commits

Author SHA1 Message Date
Tim Neutkens
f260328900
BREAKING CHANGE: Enable newNextLinkBehavior (#41459)
- Enable newNextLinkBehavior. See #36436 
- Run next/link codemod on test suite

Note that from when this lands on apps trying canary will need to run
the new-link codemod in order to upgrade.
Ideally we have to detect `<a>` while rendering the new link and warn
for it.

Co-authored-by: Steven <steven@ceriously.com>
2022-10-17 21:20:28 -04:00
Naoyuki Kanezawa
b522b94cce
feat(next): Support has match and locale option on middleware config (#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 https://github.com/vercel/next.js/issues/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>
2022-08-31 11:23:30 -05:00
Damien Simonin Feugas
01888dcb00
chore: restores removed tests (#39452)
### 📖 What's in there?

As part of the 4 hands work done in #39397, we accidentally removed a describe for middleware "using a single matcher with i18n" (and no base path nor trailing slash).

This PR restores it.

### 🧪 How to test?

```
pnpm testheadless --testPathPattern middleware-matcher
```

### 🆙 Note to reviewers

There's only a couple lines with meaningful change in this PR. Hide whitespaces in github's diff screen to find it more easily: https://github.com/vercel/next.js/pull/39452/files?diff=split&w=1
2022-08-10 09:53:20 +00:00
Damien Simonin Feugas
15a216b856
feat(middleware): augments / matcher with /index (#39397)
* feat(middleware): augments / matcher with /index

* fix(#39396): not invoked with i18n and trailingSlash

* add test case

* tweak matcher a bit and add tests

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-09 17:58:40 -05:00
Jiachi Liu
582cb3766d
Fix: only contain middleware in dev middleware manifest (#39217)
x-ref #39199

The change in #39199 isn't correct. Middleware manifest should only contain middleware route, so that when router navigates, it only try to apply middleware instead of checking all edge routes. This PR also changes the middleware manifest global value from array to object for easier access

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-01 13:23:24 +00:00
JJ Kasper
57c5e2a024
Update middleware matcher test for root (#37961) 2022-06-23 15:47:58 -05:00
JJ Kasper
11b13074f1
Ensure special chars in middleware matcher is handled (#37933) 2022-06-23 09:13:40 -05:00
Javi Velasco
ffa378901f
Include i18 and basePath on middleware with custom matchers (#37854)
When generating the RegExp for middleware using the `matcher` option we are not taking into consideration i18n and basePath. In this PR we include them always which should we the middleware default. In a followup PR we will provide an option to opt-out in the same way we do with rewrites and redirects defined from Next.js config.
2022-06-20 22:34:03 +00:00
JJ Kasper
f17f1d4e56
Update middleware matcher e2e test (#37694) 2022-06-14 15:11:36 -05:00
JJ Kasper
e7f08ef040
Ensure custom middleware matcher is used correctly in client manifest (#37672)
* Ensure custom middleware matcher is used correctly in client manifest

* lint-fix

* patch e2e case

* fix rsc case

* update test

* add missing normalize
2022-06-13 22:07:40 -05:00