Skip to content

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

Closed
@JohnGemstone

Description

@JohnGemstone

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions