[英]Private S3 + CloudFront react app: “XML file does not appear to have any style information associated with it”
This is a follow up question to the one found here: CloudFront + S3 Website: "The specified key does not exist" when an implicit index document should be displayed这是对此处找到的问题的后续问题: CloudFront + S3 网站:“指定的键不存在”何时应显示隐式索引文档
I am trying to host a React single page app (static website) through S3 and I want to allow https access only (using a custom SSL).我正在尝试通过 S3 托管 React 单页应用程序(静态网站),并且我想只允许 https 访问(使用自定义 SSL)。 I have everything configured with CloudFront and my website is showing up at the CloudFront URL just fine.
我用 CloudFront 配置了所有东西,我的网站在 CloudFront URL 上显示得很好。 But when I navigate around the app, I get the error shown in the link above .
但是当我浏览应用程序时,我收到上面链接中显示的错误。
According to that post, the error is fixed by switching from a REST to a website endpoint.根据该帖子,通过从 REST 切换到网站端点来修复错误。 But in the process, you have to make your S3 bucket public.
但在此过程中,您必须公开您的 S3 存储桶。 My question: is there a way to fix this error without switching to a website endpoint and, in the process, making all my S3 content public?
我的问题:有没有办法在不切换到网站端点并在此过程中公开我的所有 S3 内容的情况下修复此错误? Is there some kind of workaround within the AWS ecosystem where I can combine private S3 contents with a process that returns the html doc without the XML formatted error?
在 AWS 生态系统中是否有某种解决方法,我可以将私有 S3 内容与返回 html 文档而没有 XML 格式错误的过程相结合? According to this reference ( https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff ), this seems like it may not be possible, but I'm hoping someone can prove me wrong.
根据这个参考( https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff ),这似乎是不可能的,但我希望有人能证明我错了。
Thanks!谢谢!
The error you're getting usually occurs when your application tries to access something which it isn't privileged to.当您的应用程序尝试访问它没有特权的内容时,通常会发生您遇到的错误。
Since you mentioned the app loads normally but you get this error while you move around;由于您提到该应用程序正常加载,但您在四处移动时收到此错误; So it can be the case that it occurs when a component tries to load a private resource which you haven't added in the policies you have defined.
因此,当组件尝试加载您未在您定义的策略中添加的私有资源时,可能会发生这种情况。
My question: is there a way to fix this error without switching to a website endpoint and, in the process, making all my S3 content public?
我的问题:有没有办法在不切换到网站端点并在此过程中公开我的所有 S3 内容的情况下修复此错误?
Definitely.确实。 But you need to pin point the resources which is being accessed when you're getting the error!
但是,当您遇到错误时,您需要指出正在访问的资源! I would request you to provide more info regarding the same.
我会要求您提供有关相同的更多信息。
Lastly, if you switch to website endpoints, you won't to able to serve private S3 content.最后,如果您切换到网站端点,您将无法提供私有 S3 内容。 You'll have to make it all public.
您必须将其全部公开。 You can find more info about this here: https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff
您可以在此处找到有关此的更多信息: https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.