Skip to content
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

When Redirecting From/To URLs With Trailing Slash, URL Query Doesn't Persist #3374

Closed
5 tasks done
anatolzak opened this issue Mar 19, 2023 · 5 comments
Closed
5 tasks done
Labels
bug Something isn't working redirects

Comments

@anatolzak
Copy link

anatolzak commented Mar 19, 2023

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

d2d2aijy8ye0g3

AWS Region

us-east-1

Amplify Hosting feature

Redirects

Describe the bug

I have deployed a simple Next.js app to AWS Amplify from the following repo: https://github.com/anatolzak/nextjs-query-example

When I go to any page (except the index page) without a trailing slash and add url query params, it redirects me to the url with a trailing slash but drops my url query.

So if I go to: https://main.d2d2aijy8ye0g3.amplifyapp.com/test?query_1=true, it redirects me to https://main.d2d2aijy8ye0g3.amplifyapp.com/test/

In my next.config.js, I set trailingSlash to true so it redirects urls without a trailing slash to their counterpart with a trailing slash.
Without setting trailingSlash to true in Next.js apps, urls with a trailing slash produce 403 status code which is another issue #3373, but I am sure that if AWS Amplify redirected you from urls with a trailing slash to without a trailing slash, which is the default expected behavior for Next.js apps, I am sure AWS Amplify would still drop the query param as described above.

I can also confirm it happens with Gatsby apps as well, where they default to redirecting urls without a trailing slash to their counterpart with a trailing slash, but AWS Amplify drops the query params during the redirect as well.

But when using Vercel for both Gatsby and Next.js apps, it never drops query params when redirecting to/from urls with a trailing slash.

Expected behavior

When redirecting to/from urls with a trailing slash, url query should persist and not be deleted after the redirect.

Reproduction steps

  1. Deploy a Next.js app from this repo https://github.com/anatolzak/nextjs-query-example
  2. Delete any rewrites or redirects
  3. Go to /test?query=1, and it will redirect to /test/

Build Settings

No response

Log output

No response

Additional information

No response

@anatolzak
Copy link
Author

Is there any progress on this issue?

@anatolzak
Copy link
Author

Has there been any progress on this issue?

@anatolzak
Copy link
Author

anatolzak commented May 27, 2023

This issue doesn't occur with next.js ssr apps.
It does occur with next.js ssg apps or any other ssg apps. All my gatsby apps have the same issue as well. And this issue happens with any urls except the base path. (i.e. /test, /..., etc.)

@nadetastic nadetastic assigned Jay2113 and unassigned nadetastic Jun 12, 2023
@Jay2113
Copy link
Contributor

Jay2113 commented Mar 22, 2024

@anatolzak 👋 , we have shipped a fix for this behavior and this issue should no longer occur. Thanks for your continued patience!

@Jay2113 Jay2113 closed this as completed Mar 22, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@Jay2113 Jay2113 removed their assignment Mar 22, 2024
@aws-amplify aws-amplify locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working redirects
Projects
None yet
Development

No branches or pull requests

3 participants