[英]How can I get my HTML file to access my CSS and JavaScript files in an Amazon S3 Bucket?
I am currently trying to host an html file as a website on AWS S3 to get around the CORS Policy.我目前正在尝试在 AWS S3 上托管一个 html 文件作为网站来绕过 CORS 策略。 When I put all of my documents into a new bucket, the html file opens without accessing the css or javascript that is in the bucket with it.
当我将所有文档放入一个新存储桶时,html 文件打开时不会访问存储桶中的 css 或 javascript。 When I open the file outside of the bucket (ie from my computer).
当我在存储桶外(即从我的计算机)打开文件时。 The page opens with all the css and javascript working.
该页面打开时所有 css 和 javascript 都在工作。 I am wondering how I can get my css and javascript working within the bucket.
我想知道如何让我的 css 和 javascript 在存储桶中工作。
There are a few ideas I have that might help with the problem, but I have no idea how to implement them.我有一些想法可能有助于解决问题,但我不知道如何实施它们。 I'm not sure if there are extra permissions I must grant to my files to allow them to access each other.
我不确定是否有额外的权限必须授予我的文件以允许它们相互访问。 I'm also not sure if there is something within the code of the html file that must change.
我也不确定 html 文件的代码中是否有必须更改的内容。 Any help is much appreciated!
任何帮助深表感谢!
You can use static webhosting for a s3 bucket see [1].您可以对 s3 存储桶使用静态虚拟主机,请参阅 [1]。
Otherwise it is just a data container, where you load a file form and Context with referenced files is not matched to the bucket + path directly - I guess.否则,它只是一个数据容器,您可以在其中加载文件表单,并且带有引用文件的上下文与存储桶 + 路径不直接匹配 - 我猜。
I unfortunately don't have better explanation at the moment.不幸的是,我目前没有更好的解释。
Alternatively if the files are publicly available you could maybe also provide the full paths to the files in the bucket within the html.或者,如果文件是公开可用的,您也可以在 html 中提供存储桶中文件的完整路径。
But that is not very nice or maintainable (if it even works).但这不是很好或可维护(如果它甚至有效)。
[1] https://docs.aws.amazon.com/en_en/AmazonS3/latest/user-guide/static-website-hosting.html [1] https://docs.aws.amazon.com/en_en/AmazonS3/latest/user-guide/static-website-hosting.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.