aws amplify rewrite 502



I'm trying to use NextJS rewrite feature but it's not working as expected.

I've two amplify projects running successfully say foo (with URL and bar (with URL

I want to be rewrited to

But it's not working. When I access I get error 502. But when I access it loads fine.


  • Ajit
asked a year ago347 views
2 Answers
Accepted Answer


In your amplify app where you specify the 200 rewrite rule and in which you have the domain "" setup, can you please try adding the source as just the path i.e., "/tools/site1" and then target as "" just to check if that works.

Also, I see that setting up Rewrites across different Amplify apps is not supported with Amplify Hosting as of now. The team is aware of the same and has taken it in as feature request on the below GitHub issue.


I'd like to mention that currently you can setup a redirect instead of rewrite but that would be a change in path. You can subscribe to the above mentioned GitHub issue for the future updates on the same.

Having said that, if you are trying to setup a reverse proxy rewrite, kindly note that Amplify can only do a reverse proxy rewrite for only publicly-accessible webpages.

answered a year ago
  • Thanks Srinath.

    I also tried adding the source as just the path i.e., "/tools/site1" and then target as "", but I get the same 502 CloudFront exception.

    I think it's regarding the issue you've mentioned, Rewrites across different Amplify apps is not yet supported. We'll wait for the feature and then move our applications to Amplify.

  • Hello

    I am facing a similar issue in my amplify hosted frontend website to rewrite from path based route to a CNAME record which points to custom website hosted by another provider.

    I needed the below setup. to rewrite to which is CNAME record in my account pointing to a custom DNS provider URL. My website is in Amplify and configured with 200 rewrite rule but getting DNS errors. However the 301 redirect rule works but that is not my requirement.

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions