-
Notifications
You must be signed in to change notification settings - Fork 116
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
URL with Trailing Slash with Next.js returns 403 status code #3373
Comments
For anyone else with the same issue, a workaround for this issue, is to set After doing that, it looks like AWS Amplify redirects all urls without a trailing slash to the urls with a trailing slash. I am not sure why by default AWS Amplify can't redirect urls with trailing slashes to their counterpart without a trailing slash which is the default expected behavior for Next.js apps as described here: https://nextjs.org/docs/api-reference/next.config.js/trailing-slash It is pretty absurd that you can't deploy a Next.js app as is without finding all the different bugs that AWS Amplify has with Next.js apps and trying to find solutions to all the different problems it has to make your deployment actually work. Update: Since posting this issue, I found another issue #3374 which is that if you add query params to a url that then redirects to with/without a trailing slash, AWS Amplify drops the URL query params entirely. |
Hi @anatolzak 👋🏽 thanks for raising this issue and providing feedback. I have not been able to reproduce this on my end. I've deployed SSG and SSR apps with Next.js and navigating to paths ending Are you experiencing this behavior with any other apps you have deployed? |
@hloriii The issue doesn't occur on next.js ssr apps. Here is the SSG app I just deployed that is behaving in the above described ways: https://main.d3qwejj06ayzs0.amplifyapp.com/test/ |
Before opening, please confirm:
App Id
d17g4lsg0ngzxg
AWS Region
us-east-1
Amplify Hosting feature
Not Applicable
Describe the bug
I have deployed a simple Next.js SSG website with an index page and test page. Repository:
https://github.com/anatolzak/nextjs-trailing-slash
Pages:
https://main.d17g4lsg0ngzxg.amplifyapp.com
https://main.d17g4lsg0ngzxg.amplifyapp.com/test
And I don't have any rewrites or redirects.
When going to
https://main.d17g4lsg0ngzxg.amplifyapp.com/test
, everything works correctly. But when going to the same url but with a trailing slash, I get a 403 page.So apparently, trailing slashes don't work
Expected behavior
URLs with a Trailing slash should redirect to their counterpart without a trailing slash which is the default behavior for Next.js apps as described here: https://nextjs.org/docs/api-reference/next.config.js/trailing-slash.
Or URLs with a trailing slash should at least not return 403 status code and instead just render the same page as without a trailing slash.
Reproduction steps
Build Settings
No response
Log output
Additional information
No response
The text was updated successfully, but these errors were encountered: