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

Redirects don't preserve query params #935

Open
muffinresearch opened this issue Mar 8, 2021 · 3 comments
Open

Redirects don't preserve query params #935

muffinresearch opened this issue Mar 8, 2021 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@muffinresearch
Copy link
Contributor

muffinresearch commented Mar 8, 2021

As noted in mozilla/addons#8234 a redirect doesn't appear to preserve query params.

For example:

https://extensionworkshop.com/documentation/themes?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=dev-hub-legacy-menu-link

is redirected to:

https://extensionworkshop.com/documentation/themes/

Presumably this relates to s3 or cloudfront configuration? Can this be updated to preserve query params?

According to https://stackoverflow.com/questions/30775068/amazon-s3-redirect-rule-preserve-query-params#30798325 there's an option under CloudFront > Behaviors > Forward Query Strings. Though there are also other references in the same question that suggest this doesn't always work.

@bqbn
Copy link
Collaborator

bqbn commented Mar 10, 2021

Yeah, we already set "Query String Forwarding and Caching" to "Forward all, cache based on all", which means all query strings in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.

That's why if we go to https://extensionworkshop.com/documentation/themes/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=dev-hub-legacy-menu-link, we see the query params are preserved.

The problem lies in S3. Particularly, we previously solved the "redirect URLS without a slash to the slashed variant" problem in #586, where we leveraged the x-amz-website-redirect-location property of an object (e.g. /documentation/themes) to redirect access for that object to its slashed partner (e.g. /documentation/themes/). However, when S3 does the redirection, it drops the query params, and unfortunately, we can't configure S3 not to do that.

@muffinresearch
Copy link
Contributor Author

muffinresearch commented Mar 15, 2021

@bqbn I've filed an issue to workaround this by ensuring links don't cause a redirect for now. Are there any alternatives? Would it be possible to have cloudfront -> nginx -> s3 for example? Thinking ahead, would GCP provide a different solution that would enable redirects to work without losing query params?

@bqbn
Copy link
Collaborator

bqbn commented Mar 15, 2021

Using Nginx between CloudFront and S3 can be an option. That would require us to change the current architecture design, and maintain a couple of Nginx instances.

A second option may be to leverage the Lambda@Edge to append a slash to the path. We can try this first IMO.

The design and technology used by extensionworkshop.com are applied to a few other static websites that cloudops supports, but AFAIK, ops hasn't looked into how to implement static websites in GCP yet. The best I can tell at this point, moving static websites to GCP is low priority, and will probably happen in later 2022, if at all. That should give us some time to research and experiment how to do it later.

@rebloor rebloor added bug Something isn't working enhancement New feature or request labels Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants