从 AWS Amplify 上托管的 React 应用程序的受保护路由访问拒绝错误 [英] Access Denied Error from protected routes from react app hosted on AWS Amplify

查看:39
本文介绍了从 AWS Amplify 上托管的 React 应用程序的受保护路由访问拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AWS Amplify 上托管了我的 React 应用程序.在尝试访问应用程序的受保护路由时,我在屏幕上收到以下错误此 XML 文件似乎没有任何与之关联的样式信息.文档树如下所示.

I have hosted my react app on AWS Amplify. On trying to access a protected route of the application I am getting the following error on screen This XML file does not appear to have any style information associated with it. The document tree is shown below.

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>3C8377104116CA48</RequestId>
<HostId>nL3bDs+kXEWE8uBFPTLkFLpRg6CCmKfejftWs5wmTWYO6K6WDzpwsDXJCFTK0EFhjJdaHECfuos=</HostId>
</Error>

我该如何解决这个问题?

How do I resolve this?

推荐答案

我自己从一个 AWS 论坛中找到了一个解决方案,在该论坛中,一位用户很乐意分享他从 AWS 支持中获得的解决方案.我猜 AWS 不想让全世界知道它所造成的问题的解决方案,以便出售支持包.无论如何,这是解决方案:

I found a solution myself from one of AWS forum where a user was kind to share the solution he got from AWS support. I guess AWS does not want the world to know the solutions to the problems it creates so as to sell the support package. Anyway, here is the solution:

在重写和重定向"部分的 AWS Amplify 控制台中添加此记录

In AWS Amplify console in 'Rewrites and Redirects' section add this record

Source Address: </^((?!\.(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$).)*$/>
Target: /index.html
Type: 200 (Rewrite)

就是这样.它神奇地得到解决.我不知道为什么必须这样做或首先出了什么问题,但采取此措施可以解决问题.

That is it. It magically gets resolved. I don't know why this has to be done or what went wrong in the first place, but taking this action resolves it.

这篇关于从 AWS Amplify 上托管的 React 应用程序的受保护路由访问拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆