-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
skipTrailingSlashRedirect option is not being applied #54984
Comments
@blauakqa I think
|
Thanks William, To clarify are you implying that skipTrailingSlashRedirect property is only for after the user clicks the link? If you go to the homepage from the repo, we wish to preserve the URL as is:
If that’s not the case, apart from patching the code is there a way to achieve this desired behaviour of preserving the URL? Cheers, |
To summarise:
|
After some bisecting, I could trace this to a regression between |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue or a replay of the bug
https://github.com/blauakqa/nextjs-trailing-slash-issue
To Reproduce
To replicate:
Current vs. Expected behavior
Expect the rendered url
/link-with-slash/
to have atrailing slash
under theLinks with trailing slash
headerActual result is the trailing slash is removed
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 Binaries: Node: 18.12.1 npm: 8.19.2 Yarn: 1.22.15 pnpm: 6.11.0 Relevant Packages: next: 13.4.20-canary.15 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: N/A Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Routing (next/router, next/navigation, next/link)
Additional context
We have skipTrailingSlashRedirect set to true.
If we set breakpoints, we can see that on line 294 of
webpack-config.js
,config.skipTrailingSlashRedirect
istrue
.However, when we hit line 14 of
normalize-trailing-slash.js
,process.env.__NEXT_MANUAL_TRAILING_SLASH
isundefined
in thenormalizePathTrailingSlash
functionIf we manually set
__NEXT_MANUAL_TRAILING_SLASH
totrue
via a .env file, it works as expected.The supplied example has two urls
When you run the example, have noticed the following when
normalizePathTrailingSlash
function is executedpath
parameter is/link-with-slash/
and the value ofprocess.env.__NEXT_MANUAL_TRAILING_SLASH
isundefined
path
parameter is/link-with-slash
and the value ofprocess.env.__NEXT_MANUAL_TRAILING_SLASH
istrue
- trailing slash is already removedHave tried it on the following NextJS versions and the issue still occurs locally and on Vercel
Cheers
NEXT-1599
The text was updated successfully, but these errors were encountered: