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

fix: enable hard navigate on 404 #71198

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

abvthecity
Copy link
Contributor

@abvthecity abvthecity commented Oct 12, 2024

Related to #71194 and #71193

Additional feature flag that will enable hard navigate on /404 routes.

Why

Given the following proxy setup:

rewrites:
 - source: /(!?internal/):path*
   destination: https://another-nextjs-site.vercel.app/:path*

the client-side router is unaware that /internal/* belongs to the parent, and will render a 404 page.

How

Adding a hardNavigate404=true flag will always hard navigate on 404.

@ijjk
Copy link
Member

ijjk commented Oct 12, 2024

Allow CI Workflow Run

  • approve CI run for commit: 062c793

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@@ -1776,6 +1776,10 @@ export default class Router implements BaseRouter {
routeInfo.props.pageProps.statusCode = 500
}

if (this.pathname === '/404' && process.env.__NEXT_HARD_NAVIGATE_404) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking instead of hard-coding this behavior to /404 if we provide an experimental config to allow providing custom paths to the client router filter which allows specifying paths/partial paths that should trigger hard navigations.

x-ref:

export function createClientRouterFilter(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants