amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Redirect strips query params

Open DevPowers opened this issue 2 years ago • 5 comments

Before opening, please confirm:

App Id

d1op66f9k171p6

Region

us-east-1

Amplify Hosting feature

Redirects

Describe the bug

  1. When navigating to my website via the URL:
    'example.com?query1=query1' domain is redirected -> 'www.example.com' stripping the query params

Expected behavior

  1. When navigating to my website via the URL:
    'example.com?query1=query1' domain is redirected -> 'www.example.com?query1=query1'

  2. The expected behavior works for my subdomains but not the main domain. 'subdomain.example.com?query1=query1' domain is redirected -> 'www.subdomain.example.com?query1=query1'

Reproduction steps

  1. I can trigger the bug by entering my domain without the WWW and query params. The result is being navigated to the WWW domain with query params stripped.

Build Settings

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npx ci
    build:
      commands:
        - if [[("${AWS_BRANCH}" = "develop")]]; then npm run build:sandbox; fi
        - if [[("${AWS_BRANCH}" = "main")]]; then npm run build:sandbox; fi
        - if [[("${AWS_BRANCH}" != "main") && ("${AWS_BRANCH}" != "develop")]]; then npm run build:sandbox; fi
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Additional information

No response

DevPowers avatar Sep 05 '22 22:09 DevPowers

My team is having this same issue.

The workaround detailed here doesn't seem to work for us: https://github.com/aws-amplify/amplify-hosting/issues/886#issuecomment-668249281

I've added a redirect for https://mydomain.io/<*> to https://www.mydomain.io/<*> but it doesn't seem to make a difference.

davidaugustus-focusmate avatar Sep 19 '22 21:09 davidaugustus-focusmate

Hi @DevPowers and @davidaugustus-focusmate 👋🏽 apologies for the delay. According to the Amplify documentation, dropping the query params is intended behavior:

If the destination address for the matching rule has query parameters, query parameters aren't forwarded. For example, if the destination address for the redirect is https://example-target.com?q=someParam, query parameters aren't passed through.

Please read more about implementing query params here: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#query-parameters

ghost avatar Oct 03 '22 23:10 ghost

Closing as a duplicate of #97

ghost avatar Oct 04 '22 22:10 ghost

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Oct 04 '22 22:10 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Oct 28 '22 00:10 github-actions[bot]