简体   繁体   English

使用 aws s3 和 cloudfront 托管 React 应用程序。任何人都可以建议配置以访问动态 url 吗?

[英]Using aws s3 and cloudfront to host React application.Can anyone suggest configuration to access dynamic urls?

For eg website url is https://www.myreactapp.com .例如网站 url 是https://www.myreactapp.com It has some other pages with dynamic get parameters.它还有其他一些带有动态获取参数的页面。

https://www.myreactapp.com/category/1 https://www.myreactapp.com/category/1

https://www.myreactapp.com/category/2 https://www.myreactapp.com/category/2

It's giving me Access Denied error它给了我拒绝访问错误

The solution for the OP was to update the origin from S3 to Custom Origin domain. OP 的解决方案是将源从 S3 更新为自定义源域。 This allowed expected behaviour to work.这允许预期的行为起作用。

Validated that bucket was public, error 403 was caused by key not existing.验证存储桶是公开的,错误 403 是由不存在的密钥引起的。

I had the same issue where i'm trying to access content at run time using ajax.我有同样的问题,我试图在运行时使用 ajax 访问内容。

Set S3 bucket Access as "Objects can be public", No need to set "Public" Access for Static website hosting.将 S3 存储桶访问权限设置为“对象可以公开”,Static 网站托管无需设置“公开”访问权限。

Use S3 Origin if you want CloudFront to deliver any objects that place in S3 bucket.如果您希望 CloudFront 传送放置在 S3 存储桶中的任何对象,请使用S3 Origin But if you generate run time content, its batter to use Custom Origin .但是如果你生成运行时内容,它的击球手使用Custom Origin

For Custom Origin keep Note: https://docs.aws.amazon.com/general/latest/gr/s3.html#s3_website_region_endpoints https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html For Custom Origin keep Note: https://docs.aws.amazon.com/general/latest/gr/s3.html#s3_website_region_endpoints https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM