DEV Community

Jamal
Jamal

Posted on

Fix AWS amplify React app error on Access Denied error

When I deployed my build react app on AWS amplify, the first landing page is able to load. However, when you defined a path in your router, and try to access it, you would hit Access Denied error:
like /signin first page loaded but unable to go /signup route or any other routes .

Alt Text

Here, what i did,

Go AWS amplify console, select “ Rewrites and redirects ”, add a new rewrite and redirects, click on “ Open text editor ”, and add the below rule:

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

Looks like this:

Alt Text

Try again to access your url, it should work now.

Stackoverflow answer:
https://stackoverflow.com/questions/63546586/access-denied-error-from-protected-routes-from-react-app-hosted-on-aws-amplify

Top comments (0)