Getting an "Access Denied" error when I reload my React app on AWS Amplify Getting an "Access Denied" error when I reload my React app on AWS Amplify reactjs reactjs

Getting an "Access Denied" error when I reload my React app on AWS Amplify


I have been facing the same error since days.The error is being caused by the amplify settings. The solution is simple,Edit your Rewrites and redirects by adding a new rule.

source address = </^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>

target address = /index.html

status = 200 (Rewrite)

Country code can be left blank

Save and try refreshing your app again. It should probably work.

use this for reference: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa


This is where you can find Redirects on your Amplify Menu

Then you can just put in (as Dhruv Godambe posted above)

</^((?!.(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$).)*$/>

as the Source address and

/index.html as your target address

This is what it looks like in AWS


You can navigate to 'rewrites and redirects' in your app from AWS Amplify console and click on edit and select open text editor, and add this piece of code in your array(if present) else put the array braces around it.

{        "source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>",        "target": "/index.html",        "status": "200",        "condition": null}

Reference: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa