Skip to content

[Bug]: Edge Middleware Functions not executing when navigating to dynamic routes with next/link + matcher #1481

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

Closed
1 of 2 tasks
JohnGemstone opened this issue Jul 24, 2022 · 1 comment · Fixed by #1612
Closed
1 of 2 tasks
Labels
type: bug code to address defects in shipped code

Comments

@JohnGemstone
Copy link

JohnGemstone commented Jul 24, 2022

Summary

Similar to the issue we ran into here except with using the top level way of defining middleware Next 12.2.0 requires. Middleware functions are executed and run expectedly on prefetches to static routes. But no middleware functions are executed on navigation to dynamic pages, user must refresh the page.

Steps to reproduce

  1. Go to the Repo Demo
  2. Navigate to Prefetch Middleware test (static pages)
  3. Observe cookie creation of ab-static-* once navigating to the subpages (most likely will prefetch)
  4. Go back and navigate to Prefetch Middleware test (dynamic pages)
  5. Observe no cookie creation of ab-dynamic-* even when navigating to subpage.
  6. Refresh the subpage and observe cookie creation and rewrite as expected.

Works fine locally on netlify dev
Can a work around removing the matcher config (preview)

A link to a reproduction repository

https://github.com/JohnGemstone/netlify-plugin-nextjs-middleware

Plugin version

4.12.2

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml`
[build]
publish = ".next"

[build.environment]
NEXT_USE_NETLIFY_EDGE = "true"

[[plugins]]
package = "@netlify/plugin-nextjs"
@JohnGemstone JohnGemstone added the type: bug code to address defects in shipped code label Jul 24, 2022
@JohnGemstone
Copy link
Author

JohnGemstone commented Aug 1, 2022

As mentioned it works fine without the 'matcher config', but my concern is that without it the number of edge function invocations will increase tenfold depending on how many static files you access on each page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant