I am trying to set up the service worker for a SPA I am making. Its hosted on AWS with S3.
我正在尝试为我正在制作的SPA设立服务工作者。它在S3上托管在AWS上。
Despite the file being in the correct place I still get the following errors
尽管文件位于正确的位置,我仍然会收到以下错误
/service-worker.js:1 The script has an unsupported MIME type ('text/js'). https://djwdy6bk7t99o.cloudfront.net/service-worker.js
/service-worker.js:1脚本具有不受支持的MIME类型('text / js')。 https://djwdy6bk7t99o.cloudfront.net/service-worker.js
Failed to load resource: net::ERR_INSECURE_RESPONSE
无法加载资源:net :: ERR_INSECURE_RESPONSE
1 个解决方案
#1
1
The service worker specification requires that the response for the service worker JavaScript file used in the registration be served with a "JavaScript MIME type" (e.g., Content-Type: application/javascript
) header.
服务工作者规范要求注册中使用的服务工作者JavaScript文件的响应与“JavaScript MIME类型”(例如,Content-Type:application / javascript)头一起提供。
That's what I'd expect the default to be for files served by S3 with a .js
extension, but perhaps you've previously overridden the default settings? This answer has some details about changing that setting back.
这就是我期望默认为S3提供的带有.js扩展名的文件的默认值,但是你可能以前覆盖了默认设置?这个答案有一些关于改变这种设置的细节。
#1
1
The service worker specification requires that the response for the service worker JavaScript file used in the registration be served with a "JavaScript MIME type" (e.g., Content-Type: application/javascript
) header.
服务工作者规范要求注册中使用的服务工作者JavaScript文件的响应与“JavaScript MIME类型”(例如,Content-Type:application / javascript)头一起提供。
That's what I'd expect the default to be for files served by S3 with a .js
extension, but perhaps you've previously overridden the default settings? This answer has some details about changing that setting back.
这就是我期望默认为S3提供的带有.js扩展名的文件的默认值,但是你可能以前覆盖了默认设置?这个答案有一些关于改变这种设置的细节。