首页 文章

提供来自Google Cloud 端存储的单页React应用

提问于
浏览
1

我正在尝试从Google Cloud 端存储中提供React应用 . 我构建了React项目并将 build/ 目录的内容上传到Google Cloud Storage . 我确保里面的每个文件都是公开访问的 . 但是当我转到我的Google Cloud存储桶链接http://storage.googleapis.com/BUCKET_NAME/时,我得到一些关于权限错误的XML:

<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>
Anonymous users does not have storage.objects.list access to bucket BUCKET_NAME.
</Details>
</Error>

然后,我尝试导航到URL http://storage.googleapis.com/BUCKET_NAME/index.html,这会打开一个空白页面 . 在JS控制台中,有错误:

index.html:1 GET http://storage.googleapis.com/static/css/main.9a0fe4f1.css 
index.html:1 GET http://storage.googleapis.com/static/js/main.871fec8f.js

这些错误看起来像BUCKET_NAME不在提取的URL中 . 但是,我构建的index.html相对引用它们,如下所示:

<script type="text/javascript" src="/static/js/main.871fec8f.js"></script>

我不确定发生了什么,有两个问题 . 首先,当转到存储区URL时,index.html不是默认的服务页面 . 第二个问题是相对路径似乎没有解析正确的URL . 任何帮助表示赞赏 .

1 回答

  • 1

    这是我的问题 . 这种方法应该有效 .

相关问题