阅读背景:

如何将响应项目部署到AWS s3

来源:互联网 

I tried to deploy react project to s3, and I followed every step of this instruction. https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af

我试图将反应项目部署到s3,然后我遵循了该指令的每一步。 https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af

However, I cannot see my project on s3 server, and I always get these 2 errors.

但是,我无法在s3服务器上看到我的项目,而且我总是得到这两个错误。

Uncaught SyntaxError: Unexpected token <
Failed to load resource: the server responded with a status of 403 (Forbidden)

Can anyone tell me how to solve this problem? Should I change anything?

谁能告诉我如何解决这个问题?我该改变什么吗?

Here is the file structore

这是文件结构

Here is the first three lines of generated main.js

这是生成的main.js的前三行

!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="/",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var n=t.slice(1),r=e[t[0]];return function(e,t,o){r.apply(this,[e,t,o].concat(n))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,n){

1 个解决方案

#1


1  

It seems like your cloudfront origin access identity has no permission to access your s3 bucket. You have to update the bucket policy to allow access from cloudfront or update the cloud front origin settings to create an origin identity and automatically update bucket policy.

您的云端源访问标识似乎无权访问您的s3存储桶。您必须更新存储桶策略以允许从云端访问或更新云端源设置以创建源标识并自动更新存储桶策略。

You can do this from cloud front, by going to origins and editing the s3 origin as in the following screen shot.

您可以从云端前进,通过转到原点并编辑s3原点,如下面的屏幕截图所示。

Else if you want to do this from s3 bucket, have a look at the topic "Granting Permission to an Amazon CloudFront Origin Identity" in the following aws documentation.

否则,如果您想从s3存储桶执行此操作,请查看以下aws文档中的“授予对Amazon CloudFront Origin Identity的权限”主题。

https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-6

https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-6


分享到: