aws amplify rewrite 502

0

Hello,

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 https://foo.mydomain.com) and bar (with URL https://bar.mydomain.com).

I want https://foo.mydomain.com/tools/site1 to be rewrited to https://bar.mydomain.com.

But it's not working. When I access https://mydomain.com/tools/site1 I get error 502. But when I access https://bar.mydomain.com it loads fine.

Thanks.

  • Ajit
Secfi
asked 10 months ago319 views
2 Answers
0
Accepted Answer

Hello,

In your amplify app where you specify the 200 rewrite rule and in which you have the domain "https://foo.mydomain.com/" setup, can you please try adding the source as just the path i.e., "/tools/site1" and then target as "https://bar.mydomain.com" 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.

[+] https://github.com/aws-amplify/amplify-hosting/issues/2601

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.

AWS
Srinath
answered 10 months ago
  • Thanks Srinath.

    I also tried adding the source as just the path i.e., "/tools/site1" and then target as "https://bar.mydomain.com", 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.

    test.domain.com/blog to rewrite to blog.domain.com 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.

0
profile picture
EXPERT
answered 10 months 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