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

Rewrites and redirects per environment

Open watilde opened this issue 4 years ago • 12 comments

Is your feature request related to a problem? Please describe. As a developer, I want to test redirection rules for only dev environment so that I do not affect production environment.

Describe the solution you'd like Having an option "environment" to rewrite and redirects.

Alternative solutions

  1. Having an environment variable
  2. Set environment query string with https://github.com/aws-amplify/amplify-console/issues/97#issuecomment-906172145

Additional context A user wants to build an app on ECS on the same domain with the other app on ECS. They are considering to design Multi Origin with CloudFront, but it'd be easier if Rewrites and redirects can connect to an endpoint of ALB. In addition, their Amplify app has dev, prod environment and using environment variable to set into target address would unblock the challenge.

watilde avatar Aug 26 '21 08:08 watilde

This is currently not possible. As a workaround, you can create two apps within Amplify console - Prod and Dev. Your Prod app will only have your production branch, and your dev app can contain all your staging and feature branches.

swaminator avatar Aug 26 '21 16:08 swaminator

+1 to this

wgins avatar Oct 19 '21 19:10 wgins

this would be a great feature. as long as two amplify apps vs one w/ two envs doesn't impact my cost, its a very reasonable workaround

m1stermanager avatar Apr 08 '22 15:04 m1stermanager

We need this feature.

kumada15 avatar Jul 12 '22 11:07 kumada15

+1 to this

parkournick2 avatar Sep 06 '22 13:09 parkournick2

+1 to this

richbnaks7 avatar Oct 12 '22 15:10 richbnaks7

Agreed. +1 to this.

Etep15 avatar Jan 10 '23 03:01 Etep15

+1 to this

codingloop avatar May 25 '23 17:05 codingloop

Use case:

  • Amplify is used to host next-JS SSR apps
  • REST API's are served through different servers

Have dev environment, say using the domain abc.dev the clients to set their own subdomain, so the clients will be using the URL's like below:

  • dan.abc.dev
  • codingloop.abc.dev

A REST call would be like this https://dan.abc.dev/api/some-url and it needs to be redirected to server (ex: https://my-dev-app.elasticbeanstalk.com)

Now, these redirections should be based on the environment. Ex:

  • (Dev environment) https://dan.abc.dev/api/some-url => https://my-dev-app.elasticbeanstalk.com
  • (Prod environment) https://dan.abc.prod/api/some-url => https://my-prod-app.elasticbeanstalk.com

Due to corporate firewall policies, if the REST calls are made directly to https://my-prod-app.elasticbeanstalk.com from next.js app - they are blocked by CORS policy

codingloop avatar May 25 '23 18:05 codingloop

+1

shemekhe avatar Apr 23 '24 18:04 shemekhe

+1 similar but different use case to @codingloop where we need to redirect different env domains to specific DAM urls

jimlundblad avatar May 03 '24 10:05 jimlundblad