上载到AWS时找不到Index.html脚本文件

时间:2019-05-20 12:50:59

标签: amazon-web-services amazon-s3 aws-lambda

我正在使用Windows 10家庭版。我有一个前端应用程序,可以在计算机浏览器上显示。我已将前端上传到AWS上的S3存储桶。我将Lambda用于后端。我在index.html中添加了一些js文件,这些文件在上传到S3存储桶时找不到。

此Index.html文件可在我的计算机上找到。当上传到AWS时找不到js文件。

<body>
 <app-root></app-root>

<script type="text/javascript" src="runtime.js"></script><script 
type="text/javascript" 
src="polyfills.js"></script><script type="text/javascript" src="styles.js"> 
</script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script></body>
</html>

这是AWS浏览器上的错误:

styles.js:1 Failed to load resource: the server responded with a status of 
404 ()
polyfills.js:1 Failed to load resource: the server responded with a status of 
404 ()
runtime.js:1 Failed to load resource: the server responded with a status of 
404 ()
main.js:1 Failed to load resource: the server responded with a status of 404 
()
polyfills.js:1 Failed to load resource: the server responded with a status of 
404 ()

1 个答案:

答案 0 :(得分:0)

对于那些有相同问题的人,我的存储桶缺少以下设置:

  1. 打开您的 AWS管理控制台并导航到S3服务;

  2. 打开您遇到问题“ your_file.extension:1无法加载资源:服务器响应状态为404()”的存储桶

  3. 单击属性,然后检查是否启用了静态Web托管(如果已启用)

SW Properties

  1. 如果未启用,请确保告知正确的信息,并选择“使用此存储桶托管网站”选项,并告知索引文档:

Static Website Hosting

来源https://docs.aws.amazon.com/AmazonS3/latest/user-guide/static-website-hosting.html

相关问题