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
trailingSlash does not work in next-auth@v5 #10127
Comments
I was having the same issue. Needed to turn off |
@stefanullinger Yes, I realized that I need to disable it for it to work. |
The error in question was introduced in commit fc358df. So, what we've got here:
The actual error happens at
Three of the easiest ways to solve:
Or use some other approach. @chrislambe @balazsorban44 it's your call :) I can save you some time by creating a PR with changes once we settle on the approach. |
I think you'll find that this behavior was not introduced in fc358df since the previous implementation: const [_, actionAndProviderId] = "/api/auth/callback/credentials/".split("/api/auth")
const b = actionAndProviderId.replace(/^\//, "").split("/") ...and the current implementation: const [_, actionAndProviderId] = "/api/auth/callback/credentials/".match(new RegExp(`^/api/auth(.+)`))
const b = actionAndProviderId.replace(/^\//, "").split("/") ...produce the same value for But since I'm here, I'll cast my vote for the third suggested option: const b = actionAndProviderId.replace(/\/$/, '').replace(/^\//, '').split("/") ...or, if a case like const b = actionAndProviderId.replace(/\/+$/, '').replace(/^\//, '').split("/") Might be able to take both slashes out in a single method call but it might be better to just keep it simple. |
sorry to ask, any news on this one? |
@lurepheonix @chrislambe thanks for diving into this and suggesting some solutions! I've opened a PR basically following suggestion Let me know if that works for yall 👍 |
Environment
System:
OS: macOS 14.4
CPU: (10) arm64 Apple M1 Max
Memory: 256.14 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.8.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.5 - /usr/local/bin/npm
pnpm: 8.15.4 - /usr/local/bin/pnpm
bun: 1.0.0 - ~/.bun/bin/bun
Browsers:
Chrome: 122.0.6261.69
Safari: 17.4
npmPackages:
next: latest => 14.1.0
next-auth: beta => 5.0.0-beta.13
react: ^18.2.0 => 18.2.0
Reproduction URL
https://github.com/ablackoff/next-auth-example
Describe the issue
When adding
trailingSlash: true
to thenext.config.js
file, the following error occurs:In the browser:
In the console:
Exactly the same behavior with the Credentials provider.
This problem started with version "next-auth": "5.0.0-beta.6" and higher
How to reproduce
Go to the "Sign in" button, then "Sign in with GitHub", then you will immediately go to the error
Expected behavior
Must go to Github authorization. Don't get the error "Error: This action with HTTP POST is not supported."
The text was updated successfully, but these errors were encountered: