Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
e7409af2
Commit
e7409af2
authored
Apr 03, 2026
by
Jimmy Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: consolidate nextUrl clearing to single location
parent
3111aea6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
navigate-reducer.ts
...nt/components/router-reducer/reducers/navigate-reducer.ts
+1
-7
navigation.ts
...es/next/src/client/components/segment-cache/navigation.ts
+8
-8
No files found.
packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts
View file @
e7409af2
...
@@ -42,12 +42,6 @@ export function navigateReducer(
...
@@ -42,12 +42,6 @@ export function navigateReducer(
const
currentUrl
=
new
URL
(
state
.
canonicalUrl
,
location
.
origin
)
const
currentUrl
=
new
URL
(
state
.
canonicalUrl
,
location
.
origin
)
const
currentRenderedSearch
=
state
.
renderedSearch
const
currentRenderedSearch
=
state
.
renderedSearch
// Clear nextUrl for same-page navigations to avoid re-triggering
// interception rewrites. When the user navigates to the same URL they're
// already on, we should not send the Next-Url header that would cause the
// server to apply interception rewrites again.
const
nextUrl
=
url
.
href
===
currentUrl
.
href
?
null
:
state
.
nextUrl
return
navigateUsingSegmentCache
(
return
navigateUsingSegmentCache
(
state
,
state
,
url
,
url
,
...
@@ -55,7 +49,7 @@ export function navigateReducer(
...
@@ -55,7 +49,7 @@ export function navigateReducer(
currentRenderedSearch
,
currentRenderedSearch
,
state
.
cache
,
state
.
cache
,
state
.
tree
,
state
.
tree
,
nextUrl
,
state
.
nextUrl
,
FreshnessPolicy
.
Default
,
FreshnessPolicy
.
Default
,
scrollBehavior
,
scrollBehavior
,
navigateType
navigateType
...
...
packages/next/src/client/components/segment-cache/navigation.ts
View file @
e7409af2
...
@@ -60,12 +60,12 @@ export function navigate(
...
@@ -60,12 +60,12 @@ export function navigate(
scrollBehavior
:
ScrollBehavior
,
scrollBehavior
:
ScrollBehavior
,
navigateType
:
'push'
|
'replace'
navigateType
:
'push'
|
'replace'
):
AppRouterState
|
Promise
<
AppRouterState
>
{
):
AppRouterState
|
Promise
<
AppRouterState
>
{
//
Clear nextUrl for same-page navigations to avoid re-triggering
//
When navigating to the same URL, clear nextUrl so the Next-Url header is
//
interception rewrites. This applies to both link clicks and programmatic
//
not sent. This prevents the server from re-applying interception rewrites,
//
navigations (e.g. router.push, router.replace).
//
which would incorrectly re-trigger intercepting routes on same-page
if
(
url
.
href
===
currentUrl
.
href
)
{
// navigations (e.g. router.push, router.replace, link clicks).
nextUrl
=
null
// See: https://github.com/vercel/next.js/issues/82934
}
const
effectiveNextUrl
=
url
.
href
===
currentUrl
.
href
?
null
:
nextUrl
// Instant Navigation Testing API: when the lock is active, ensure a
// Instant Navigation Testing API: when the lock is active, ensure a
// prefetch task has been initiated before proceeding with the navigation.
// prefetch task has been initiated before proceeding with the navigation.
...
@@ -84,7 +84,7 @@ export function navigate(
...
@@ -84,7 +84,7 @@ export function navigate(
currentRenderedSearch
,
currentRenderedSearch
,
currentCacheNode
,
currentCacheNode
,
currentFlightRouterState
,
currentFlightRouterState
,
n
extUrl
,
effectiveN
extUrl
,
freshnessPolicy
,
freshnessPolicy
,
scrollBehavior
,
scrollBehavior
,
navigateType
navigateType
...
@@ -99,7 +99,7 @@ export function navigate(
...
@@ -99,7 +99,7 @@ export function navigate(
currentRenderedSearch
,
currentRenderedSearch
,
currentCacheNode
,
currentCacheNode
,
currentFlightRouterState
,
currentFlightRouterState
,
n
extUrl
,
effectiveN
extUrl
,
freshnessPolicy
,
freshnessPolicy
,
scrollBehavior
,
scrollBehavior
,
navigateType
navigateType
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment