Skip to content

Amplify 403 Error

0

We are encountering 403 Forbidden errors when accessing paths rewritten to one of our Amplify sub-apps. Specifically, requests to https://our-main-app.com/v2/* are configured with 200 (Rewrite) rules pointing to https://some-other-build.amplifyapp.com/* . While these rules appear correct in the Amplify console, all rewritten /v2/* paths result in a 403 from CloudFront. The issue is not consistent. It appears intermittently after some refreshes or at random timestamps.

We've confirmed: Rewrites are set using regex: </^((?!.).)*$> → /index.html (200 - Rewrite) No missing artifacts in the build output All other rewrites (e.g. /v3, /record) behave correctly No misconfigurations in domain management Also Checked WAF rules and Logs no traffic is blocked

Error

NOTE- This issue occurs randomly when we refresh the page. Sometimes, we get an error, but if we refresh again, it works fine. It happens frequently and is not related to the build process it occurs after the app is deployed and accessed.

2 Answers
4
EXPERT

answered a year ago

  • This issue occurs randomly when we refresh the page. Sometimes, we get an error, but if we refresh again, it works fine. It happens frequently and is not related to the build process — it occurs after the app is deployed and accessed.

0

Hey,

Hope you're keeping well.

Intermittent 403s from Amplify rewrites usually point to CloudFront caching of an error response or an origin mismatch. When you rewrite /v2/* requests to another Amplify app, CloudFront still enforces origin access, so if the secondary app’s domain isn’t correctly mapped to the same CloudFront distribution or doesn’t have that path allowed, you’ll get 403s. Try running a full cache invalidation in the Amplify console under Hosting > App settings > Clear cache to ensure stale 403s aren’t being served. Also verify the rewrite target is using its own build’s `index.

Thanks and regards,
Taz

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.