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

docs: inform middleware usage along with metadata files #69136

Conversation

devjiwonchoi
Copy link
Member

@devjiwonchoi devjiwonchoi commented Aug 21, 2024

What?

When the user sets robots.ts, sitemap.ts, or other metadata files with middleware.ts, it may end in unexpected behavior if the middleware matcher is not set to ignore the corresponding paths.

Why?

The docs are missing the information for the users to "configure middleware matcher if you have one along with generating metadata files to prevent route interference".

How?

Updated the docs to add the matcher configuration as:

export const config = {
  matcher: [
    /*
     * Match all request paths except for the ones starting with:
     * - api (API routes)
     * - _next/static (static files)
     * - _next/image (image optimization files)
     * - favicon.ico, sitemap.xml, robots.txt (metadata files) <--- combined here
     */
    '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)',
  ],
}

Added a "Good to Know" at the entry of metadata API to configure the middleware matcher if used.

Closes NDX-219

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Aug 21, 2024
Copy link
Member Author

devjiwonchoi commented Aug 21, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @devjiwonchoi and the rest of your teammates on Graphite Graphite

@devjiwonchoi devjiwonchoi marked this pull request as ready for review August 21, 2024 09:11
Copy link

graphite-app bot commented Aug 21, 2024

Graphite Automations

"Notification" took an action on this PR • (08/21/24)

1 teammate was notified to this PR based on Wyatt Johnson's automation.

Copy link
Member

@huozhi huozhi left a comment

Choose a reason for hiding this comment

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

We'd better have a test to cover the case configured middleware matcher with sitemap.xml

@delbaoliveira
Copy link
Contributor

delbaoliveira commented Aug 21, 2024

Thank you for the docs update @devjiwonchoi 🙏🏼

Copy link
Member Author

devjiwonchoi commented Aug 21, 2024

Merge activity

  • Aug 21, 9:38 AM EDT: @devjiwonchoi started a stack merge that includes this pull request via Graphite.
  • Aug 21, 9:41 AM EDT: Graphite rebased this pull request as part of a merge.
  • Aug 21, 9:48 AM EDT: @devjiwonchoi merged this pull request with Graphite.

@devjiwonchoi devjiwonchoi changed the base branch from 08-21-docs_add_missing_semi-colons_to_good_to_knows to graphite-base/69136 August 21, 2024 13:39
@devjiwonchoi devjiwonchoi changed the base branch from graphite-base/69136 to canary August 21, 2024 13:39
@devjiwonchoi devjiwonchoi force-pushed the 08-21-docs_inform_middleware_usage_along_with_metadata_files branch from 448d79b to e2439cb Compare August 21, 2024 13:40
@devjiwonchoi devjiwonchoi merged commit 8ff0b37 into canary Aug 21, 2024
54 checks passed
@devjiwonchoi devjiwonchoi deleted the 08-21-docs_inform_middleware_usage_along_with_metadata_files branch August 21, 2024 13:48
devjiwonchoi added a commit that referenced this pull request Aug 21, 2024
Add test to confirm that the middleware affects the sitemap path if the
matcher is misconfigured.

Following of #69136
Closes NDX-221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants