Skip to content

feat: add support for Next 12.3 middleware matchers #1612

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

Merged
merged 9 commits into from
Sep 9, 2022

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Sep 9, 2022

Summary

Adds support for 12.3 middleware matchers, including has and locale support.

Test plan

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Fixes #1602. FIxes #1481. Fixes https://github.com/netlify/pod-ecosystem-frameworks/issues/230

capy and duck

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for next-hp-edge-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/next-hp-edge-demo/deploys/631b373f9e834e0007d543bf
😎 Deploy Preview https://deploy-preview-1612--next-hp-edge-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/631b373fd712fe0008cea93b
😎 Deploy Preview https://deploy-preview-1612--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Sep 9, 2022
@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/631b373fde11790009eaf259
😎 Deploy Preview https://deploy-preview-1612--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/631b373fc956e400084b979d
😎 Deploy Preview https://deploy-preview-1612--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Comment on lines +214 to +215
value = value
.replace(/(:|\*|\?|\+|\(|\)|\{|\})/g, '\\$1')

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.
@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/631b373fd1593b0009ad9431
😎 Deploy Preview https://deploy-preview-1612--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/631b373f7c0a64000977fd2b
😎 Deploy Preview https://deploy-preview-1612--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/631b373f52f6d300080675d2
😎 Deploy Preview https://deploy-preview-1612--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo canceled.

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/631b5d41bc29881981e82cc9

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/631b373fa7cf3d00090431fa
😎 Deploy Preview https://deploy-preview-1612--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/631b373f92184f0007539a9c
😎 Deploy Preview https://deploy-preview-1612--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 9, 2022

Deploy Preview for next-plugin-rsc-demo failed.

Name Link
🔨 Latest commit 9b1ae7b
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/631b373fdcfcea0008828ad2

@ascorbic ascorbic force-pushed the mk/middleware-matcher branch 3 times, most recently from 2452624 to dde04aa Compare September 9, 2022 11:17
@ascorbic ascorbic force-pushed the mk/middleware-matcher branch from dde04aa to f0fb695 Compare September 9, 2022 11:20
@ascorbic ascorbic marked this pull request as ready for review September 9, 2022 13:02
@ascorbic ascorbic requested a review from a team September 9, 2022 13:02
@@ -83,7 +83,7 @@ export const buildResponse = async ({
const transformed = response.dataTransforms.reduce((prev, transform) => {
return transform(prev)
}, props)
return context.json(transformed)
return new Response(JSON.stringify(transformed), response)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"next": "^12.2.6-canary.12",
"next": "^12.2.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've temporarily set this to the old version so we can test backward-compat

Copy link
Contributor

@orinokai orinokai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks sound, but did run into a couple of issues following the test plan:

  1. When requesting the data route (with or without the request header) I got the x-is-deno header, but not the x-middleware-next header (but I'm wondering if that's normal for a data route?).
  2. Very strangely, when I first tested the middleware demo (deployed to Netlify) and hit the first link on the page, /shows/rewriteme, the middleware didn't run and I got 'This should have been rewritten', instead of the /shows/100 content. However, I can't reproduce this again (I've tried re-deploying a couple of times).

So... assuming the above 2 issues are, in fact, non-issues, then it's good to go.

@ascorbic
Copy link
Contributor Author

ascorbic commented Sep 9, 2022

@orinokai 🤦🏻‍♂️ I meant x-modified-edge, not x-middleware-next. On that basis I think it's good to go, if you're happy

@kodiakhq kodiakhq bot merged commit fd88b98 into main Sep 9, 2022
@kodiakhq kodiakhq bot deleted the mk/middleware-matcher branch September 9, 2022 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
2 participants