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 has route field #22341

Merged
merged 20 commits into from
Mar 24, 2021
Merged

Add has route field #22341

merged 20 commits into from
Mar 24, 2021

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Feb 19, 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

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk ijjk marked this pull request as ready for review February 19, 2021 17:42
@ijjk

This comment has been minimized.

@ijjk ijjk dismissed a stale review via 0919aea February 26, 2021 17:22
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

kodiakhq bot pushed a commit to vercel/vercel that referenced this pull request 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
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk ijjk requested a review from shuding as a code owner March 21, 2021 23:54
@ijjk

This comment has been minimized.

@ijjk
Copy link
Member Author

ijjk commented Mar 22, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
buildDuration 10.7s 10.7s ⚠️ +20ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +18.7 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
/ failed reqs 0 0
/ total time (seconds) 1.796 1.795 0
/ avg req/sec 1392.21 1392.42 +0.21
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.124 1.153 ⚠️ +0.03
/error-in-render avg req/sec 2224.78 2168.77 ⚠️ -56.01
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js add/has-route-field Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js add/has-route-field Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary ijjk/next.js add/has-route-field Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js add/has-route-field Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Rendered Page Sizes
vercel/next.js canary ijjk/next.js add/has-route-field Change
index.html gzip 612 B 612 B
link.html gzip 621 B 621 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
buildDuration 11.9s 12s ⚠️ +97ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +18.7 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js add/has-route-field Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js add/has-route-field Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary ijjk/next.js add/has-route-field Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js add/has-route-field Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
_error.js 1.02 MB 1.02 MB ⚠️ +4.68 kB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.6 kB 10.6 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.02 MB 1.02 MB ⚠️ +4.68 kB
link.js 1.08 MB 1.08 MB ⚠️ +4.68 kB
routerDirect.js 1.07 MB 1.07 MB ⚠️ +4.68 kB
withRouter.js 1.07 MB 1.07 MB ⚠️ +4.68 kB
Overall change 5.27 MB 5.3 MB ⚠️ +23.4 kB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
buildDuration 12.1s 12.4s ⚠️ +304ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +18.7 kB
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js add/has-route-field Change
/ failed reqs 0 0
/ total time (seconds) 1.756 1.783 ⚠️ +0.03
/ avg req/sec 1423.89 1401.74 ⚠️ -22.15
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.126 1.085 -0.04
/error-in-render avg req/sec 2219.93 2303.37 +83.44
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js add/has-route-field Change
597-12fee761..569d.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 7.11 kB 7.11 kB
webpack-HASH.js gzip 993 B 993 B
Overall change 60.7 kB 60.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js add/has-route-field Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js add/has-route-field Change
_app-b5edc60..e5c2.js gzip 1.29 kB 1.29 kB
_error-b58c1..9b8e.js gzip 3.4 kB 3.4 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-3631090..4cab.js gzip 1.65 kB 1.65 kB
routerDirect..20d7.js gzip 328 B 328 B
withRouter-b..a4b9.js gzip 326 B 326 B
Overall change 8.72 kB 8.72 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js add/has-route-field Change
_buildManifest.js gzip 325 B 325 B
Overall change 325 B 325 B
Rendered Page Sizes
vercel/next.js canary ijjk/next.js add/has-route-field Change
index.html gzip 585 B 585 B
link.html gzip 594 B 594 B
withRouter.html gzip 582 B 582 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "VjfmD82b8Bw_dD4og-z93",
+        "buildId": "3Q1Zmnnvm6MIa5ywrmEYP",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/VjfmD82b8Bw_dD4og-z93/_buildManifest.js"
+      src="/_next/static/3Q1Zmnnvm6MIa5ywrmEYP/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/VjfmD82b8Bw_dD4og-z93/_ssgManifest.js"
+      src="/_next/static/3Q1Zmnnvm6MIa5ywrmEYP/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "VjfmD82b8Bw_dD4og-z93",
+        "buildId": "3Q1Zmnnvm6MIa5ywrmEYP",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/VjfmD82b8Bw_dD4og-z93/_buildManifest.js"
+      src="/_next/static/3Q1Zmnnvm6MIa5ywrmEYP/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/VjfmD82b8Bw_dD4og-z93/_ssgManifest.js"
+      src="/_next/static/3Q1Zmnnvm6MIa5ywrmEYP/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "VjfmD82b8Bw_dD4og-z93",
+        "buildId": "3Q1Zmnnvm6MIa5ywrmEYP",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/VjfmD82b8Bw_dD4og-z93/_buildManifest.js"
+      src="/_next/static/3Q1Zmnnvm6MIa5ywrmEYP/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/VjfmD82b8Bw_dD4og-z93/_ssgManifest.js"
+      src="/_next/static/3Q1Zmnnvm6MIa5ywrmEYP/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 9fe64f7

ijjk and others added 2 commits March 24, 2021 10:51
timneutkens
timneutkens previously approved these changes Mar 24, 2021
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member Author

ijjk commented Mar 24, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
buildDuration 16.6s 16.5s -159ms
nodeModulesSize 61.7 MB 61.7 MB ⚠️ +18.7 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
/ failed reqs 0 0
/ total time (seconds) 2.156 2.224 ⚠️ +0.07
/ avg req/sec 1159.5 1124.2 ⚠️ -35.3
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.314 1.376 ⚠️ +0.06
/error-in-render avg req/sec 1902.09 1817.27 ⚠️ -84.82
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js add/has-route-field Change
597-ec2335c0..e105.js gzip 13.3 kB 13.3 kB
778-b5b29537..169f.js gzip 7.06 kB 7.06 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js add/has-route-field Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js add/has-route-field Change
_app-bdbd9e6..6cfe.js gzip 1.3 kB 1.3 kB
_error-b58c1..9b8e.js gzip 3.4 kB 3.4 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-d124373..c521.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 8.76 kB 8.76 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js add/has-route-field Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Rendered Page Sizes
vercel/next.js canary ijjk/next.js add/has-route-field Change
index.html gzip 609 B 609 B
link.html gzip 615 B 615 B
withRouter.html gzip 604 B 604 B
Overall change 1.83 kB 1.83 kB

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
buildDuration 20s 19.9s -60ms
nodeModulesSize 61.7 MB 61.7 MB ⚠️ +18.7 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js add/has-route-field Change
597-ec2335c0..e105.js gzip 13.3 kB 13.3 kB
778-b5b29537..169f.js gzip 7.06 kB 7.06 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js add/has-route-field Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js add/has-route-field Change
_app-bdbd9e6..6cfe.js gzip 1.3 kB 1.3 kB
_error-b58c1..9b8e.js gzip 3.4 kB 3.4 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-d124373..c521.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 8.76 kB 8.76 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js add/has-route-field Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
_error.js 1.34 MB 1.34 MB ⚠️ +4.67 kB
404.html 2.76 kB 2.76 kB
500.html 2.75 kB 2.75 kB
amp.amp.html 10.6 kB 10.6 kB
amp.html 1.96 kB 1.96 kB
hooks.html 2.01 kB 2.01 kB
index.js 1.34 MB 1.34 MB ⚠️ +4.67 kB
link.js 1.4 MB 1.4 MB ⚠️ +4.67 kB
routerDirect.js 1.39 MB 1.39 MB ⚠️ +4.67 kB
withRouter.js 1.39 MB 1.39 MB ⚠️ +4.67 kB
Overall change 6.87 MB 6.89 MB ⚠️ +23.4 kB

Webpack 5 Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
buildDuration 16.5s 16.4s -67ms
nodeModulesSize 61.7 MB 61.7 MB ⚠️ +18.7 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js add/has-route-field Change
/ failed reqs 0 0
/ total time (seconds) 2.2 2.203 0
/ avg req/sec 1136.59 1134.81 ⚠️ -1.78
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.355 1.359 0
/error-in-render avg req/sec 1845.51 1839.84 ⚠️ -5.67
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js add/has-route-field Change
597-ec2335c0..e105.js gzip 13.3 kB 13.3 kB
778-b5b29537..169f.js gzip 7.06 kB 7.06 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js add/has-route-field Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary ijjk/next.js add/has-route-field Change
_app-bdbd9e6..6cfe.js gzip 1.3 kB 1.3 kB
_error-b58c1..9b8e.js gzip 3.4 kB 3.4 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-d124373..c521.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 8.76 kB 8.76 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js add/has-route-field Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Rendered Page Sizes
vercel/next.js canary ijjk/next.js add/has-route-field Change
index.html gzip 609 B 609 B
link.html gzip 615 B 615 B
withRouter.html gzip 604 B 604 B
Overall change 1.83 kB 1.83 kB

Diffs

Diff for index.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "_cVYQ2JxdJ9R70XPI0O74",
+        "buildId": "5k_gD4l_ONJZk3pIybvcC",
         "isFallback": false,
         "gip": true
       }
@@ -86,11 +86,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/_cVYQ2JxdJ9R70XPI0O74/_buildManifest.js"
+      src="/_next/static/5k_gD4l_ONJZk3pIybvcC/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/_cVYQ2JxdJ9R70XPI0O74/_ssgManifest.js"
+      src="/_next/static/5k_gD4l_ONJZk3pIybvcC/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -53,7 +53,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "_cVYQ2JxdJ9R70XPI0O74",
+        "buildId": "5k_gD4l_ONJZk3pIybvcC",
         "isFallback": false,
         "gip": true
       }
@@ -91,11 +91,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/_cVYQ2JxdJ9R70XPI0O74/_buildManifest.js"
+      src="/_next/static/5k_gD4l_ONJZk3pIybvcC/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/_cVYQ2JxdJ9R70XPI0O74/_ssgManifest.js"
+      src="/_next/static/5k_gD4l_ONJZk3pIybvcC/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "_cVYQ2JxdJ9R70XPI0O74",
+        "buildId": "5k_gD4l_ONJZk3pIybvcC",
         "isFallback": false,
         "gip": true
       }
@@ -86,11 +86,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/_cVYQ2JxdJ9R70XPI0O74/_buildManifest.js"
+      src="/_next/static/5k_gD4l_ONJZk3pIybvcC/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/_cVYQ2JxdJ9R70XPI0O74/_ssgManifest.js"
+      src="/_next/static/5k_gD4l_ONJZk3pIybvcC/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 000884e

@kodiakhq kodiakhq bot merged commit 75c721c into vercel:canary Mar 24, 2021
@ijjk ijjk deleted the add/has-route-field branch March 24, 2021 16:52
SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this pull request 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 pull request 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
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for route has field
4 participants