Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

612
Visualizações
Getting an "Access Denied" error when I reload my React app on AWS Amplify

I am working on a React app that's running on AWS Amplify. My React app is using the react-router-dom library to route to different components. After running amplify publish in the CLI, at the root of the app (obktraining.com) everything is fine in the browser, I can also route to other components in the app just fine as well. But when I refresh my browser while I am on a route (obktraining.com/menu), I get an Access Denied error message.

I have found other posts about similar issues regarding rewrites and redirects in Amplify, but the solutions given do not work for me.

Here is an image of the error: enter image description here

My Amplify app rewrites & redirects : enter image description here

Again, the error only displays when I refresh on a route (obktraining.com/menu or obktraining.com/drinks) not on obktraining.com. Is the issue being caused by the react-router-dom library or is it an issue with Amplify settings? I am not sure where to go from here.

over 4 years ago · Santiago Trujillo
5 Respostas
Responde à pergunta

0

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

over 4 years ago · Santiago Trujillo Relatório

0

Reference:
https://docs.aws.amazon.com/amplify/latest/userguide/manual-deploys.html


I have faced the same problem.
I was using Manual Zip File (Compressed) download (wrong).

Here is how to deploy manually correctely:

  1. Run this command
npm run build

Now a build folder will be created.

2. Compress the content of this folder
Not the content of the whole project.
You chnage directory to the build folder and Compress the content in side.

3. Upload that compressed file Inside the build directory Now this should work just fine.
:)

over 4 years ago · Santiago Trujillo Relatório

0

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

over 4 years ago · Santiago Trujillo Relatório

0

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

over 4 years ago · Santiago Trujillo Relatório

0

The correct rule should be like this:

Source address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address: /index.html
Status: 200
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda