简体   繁体   English

私有 S3 + CloudFront 反应应用程序:“XML 文件似乎没有任何与之关联的样式信息”

[英]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.

相关问题 AWS S3/Cloudfront 上的 React App 不加载 JS 内容 - React App on AWS S3/Cloudfront does not load JS content 使用 S3 和 CloudFront 反应 App url 参数 - React App url parameter with S3 and CloudFront 使用带有CloudFront的S3静态网站托管React应用程序的请求标头 - Request headers with S3 static website hosting React app with CloudFront 在管理缓存的同时使用 CloudFront 在 S3 上部署 React 应用程序的步骤? - Steps to deploy a React app on S3 with CloudFront while managing caching? Amazon S3 + Cloudfront React 应用程序完全运行但出现 404 错误 - Amazon S3 + Cloudfront React app fully working but with 404 error React,S3,CloudFront压缩。 邮编 - React, S3, CloudFront Compression. GZip 带有s3的Cloudfront不会立即通过新部署来更新页面[对React App强制执行https] - Cloudfront with s3 doesn't update the page right away with new deployment [enforce https for react app] 从 URL 中删除 index.html 在 S3 和 CloudFront 上反应应用程序 - remove index.html from URL react app on S3 and CloudFront 在 AWS S3 和 CloudFront 中托管 React 路由器应用程序时出现 403 Access Denied 错误 - Getting 403 Access Denied Errors When Hosting a React Router App in AWS S3 and CloudFront 将信息注入从 AWS CloudFront 中的 S3 源返回的请求中 - Injecting information into requests returned from S3 origins in AWS CloudFront
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM