简体   繁体   English

Google Cloud Storage 上的 React App-Js 和 Css 未加载-给出 404

[英]React App on Google Cloud Storage- Js and Css are not getting loaded- giving 404

I created react app with following command:我使用以下命令创建了反应应用程序:

npx create-react-app my-app

Then executed the command, to create build:然后执行命令,创建构建:

npm run build

Then uploaded the build folder output to gcp storage.然后将构建文件夹输出上传到 gcp 存储。

And when I am trying to access the index.html file via Link URL.当我尝试通过链接 URL 访问 index.html 文件时。 In Console I am getting 404 for Css and Js file referenced in index.html在控制台中,我为 index.html 中引用的 Css 和 Js 文件获得了 404

When I updated the index.html with correct url link of js and css, then it is working fine.当我使用 js 和 css 的正确 url 链接更新 index.html 时,它工作正常。 Is it necessary to change the js and css link reference to gcp storage url link?是否有必要将js和css链接引用改为gcp存储url链接? Can't that work with relative paths?这不能与相对路径一起使用吗?

Depends on how you uploaded your files to Cloud Storage.取决于您将文件上传到 Cloud Storage 的方式。

You can do gsutil rsync -R local-dir gs://www.example.com to recursively copy a directory tree to Cloud Storage.您可以执行gsutil rsync -R local-dir gs://www.example.com以递归方式将目录树复制到 Cloud Storage。 Which what the -R option is used for -R 选项用于什么

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

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