You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After digging through Next.js canary source, I believe the fault lies with the use of formatNextPathnameInfo:
packages/next/src/shared/lib/router/utils/format-next-pathname-info.ts
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!
Link to the code that reproduces this issue
https://github.com/ben-aggus-gateway/middlewarebug.git
To Reproduce
rewrite {
href: 'https://www.mydomain.com/_next/data/TN22pxNPSlmN59JSJ1pFb/_next/data/TN22pxNPSlmN59JSJ1pFb/support/security.json.json',
origin: 'https://www.mydomain.com',
protocol: 'https:',
username: '',
password: '',
host: 'www.mydomain.com',
hostname: 'www.mydomain.com',
port: '',
pathname: '/_next/data/TN22pxNPSlmN59JSJ1pFb/support/security.json',
search: '',
searchParams: URLSearchParams {
[Symbol(query)]: [],
[Symbol(context)]: URL {
[Symbol(context)]: URLContext {
href: 'https://www.mydomain.com/_next/data/TN22pxNPSlmN59JSJ1pFb/support/security.json',
protocol_end: 6,
username_end: 8,
host_start: 8,
host_end: 28,
pathname_start: 28,
search_start: 4294967295,
hash_start: 4294967295,
port: 4294967295,
scheme_type: 2
}
}
},
hash: ''
}
Providing "normal" URLs like /test/path will not produce the issue.
I have enabled skipMiddlewareUrlNormalize: true, in nextjs.config
Current vs. Expected behavior
Current behavior:
nexturl.href= https://www.mydomain.com/_next/data/TN22pxNPSlmN59JSJ1pFb/_next/data/TN22pxNPSlmN59JSJ1pFb/support/security.json.json
(the path seems to repeat twice)
Expected behavior:
nexturl.href should = https://www.mydomain.com/_next/data/TN22pxNPSlmN59JSJ1pFb/support/security.json when that path is provided to the redirector (and a host has been provided like our case)
This code currently works in our production Next 13.4.19 environment and produces the expected behavior.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
Middleware / Edge (API routes, runtime)
Additional context
We are running 2 next sites. The need to rewrite /_next/data URLs is due to rewriting pages from 1 site to the other for certain pages.
The text was updated successfully, but these errors were encountered: