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

Add support for route has field #22345

Closed
ijjk opened this issue Feb 19, 2021 · 3 comments · Fixed by #22341
Closed

Add support for route has field #22345

ijjk opened this issue Feb 19, 2021 · 3 comments · Fixed by #22341
Assignees
Milestone

Comments

@ijjk
Copy link
Member

ijjk commented Feb 19, 2021

A new custom routes field has should be added to match against header, cookie, and query values. Currently only paths are allowed to matched against, adding the has field allows for more specific custom routes matching. The following shape will be used:

{
  source: '/:path*',
  has: [
    {
      type: 'header' | 'cookie' | 'query',
      key: 'some-key-to-match',
      value: 'an optionanl value to match'
    }
  ],
  destination: '/another/:path*'
}

Both the source and all has fields must be matched for the custom route to be applied.

@ijjk ijjk self-assigned this Feb 19, 2021
@balazsorban44
Copy link
Member

balazsorban44 commented Feb 21, 2021

I wonder if the Next.js team has any specific usecases in mind for this!? 💡

@timneutkens
Copy link
Member

timneutkens commented Feb 22, 2021

I wonder if the Next.js team has any specific usecases in mind for this!? 💡

This is mostly driven by complex enterprise needs where they might have to route certain requests based on a cookie existing or a header being set from an external system. In general you don't need it in a basic Next.js application.

@timneutkens timneutkens added this to the iteration 17 milestone Feb 26, 2021
kodiakhq bot pushed a commit to vercel/vercel that referenced this issue Mar 11, 2021
### Related Issues

x-ref: vercel/next.js#22341
x-ref: vercel/next.js#22345

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
@kodiakhq kodiakhq bot closed this as completed in #22341 Mar 24, 2021
kodiakhq bot pushed a commit that referenced this issue Mar 24, 2021
This adds support for a `has` field to `rewrites`, `redirects`, and `headers` to allow matching against `header`, `cookie`, and `query` values. Documentation and additional tests for the feature is also added in this PR. 

Closes: #22345
SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this issue Apr 20, 2021
This adds support for a `has` field to `rewrites`, `redirects`, and `headers` to allow matching against `header`, `cookie`, and `query` values. Documentation and additional tests for the feature is also added in this PR. 

Closes: vercel#22345
flybayer pushed a commit to blitz-js/next.js that referenced this issue Apr 29, 2021
This adds support for a `has` field to `rewrites`, `redirects`, and `headers` to allow matching against `header`, `cookie`, and `query` values. Documentation and additional tests for the feature is also added in this PR. 

Closes: vercel#22345
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants