简体   繁体   English

firebaseerror:无法注册ServiceWorker

[英]firebaseerror: Failed to register a ServiceWorker

I am using create-react-app npm to install react js application. 我正在使用create-react-app npm安装react js应用程序。 I am trying to use firebase in the project. 我正在尝试在项目中使用Firebase。 I am following firebase integration in reactjs tutorial. 我正在reactjs教程中关注firebase集成 I have done all things correctly. 我正确地做了所有事情。 But I am not certain where is webpack config file. 但是我不确定webpack配置文件在哪里。 I tried inserting 我尝试插入

const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
plugins: [
  ….
  new ServiceWorkerWebpackPlugin({
     entry: path.join(__dirname, './firebase-messaging-sw.js'),
  })
]

Above code snippet to node_module/react-scripts/scripts/webpack.config.dev.js. 上面的代码段为node_module / react-scripts / scripts / webpack.config.dev.js。 But cannot get working. 但是无法工作。

I am upto asking for permission to user and after allowing the permission I see the following error. 我要向用户请求权限,并且在允许该权限后,我看到以下错误。

browserErrorMessage : "Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html')." code:"messaging/failed-serviceworker-registration" message:"Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html').

What is the error related to and how to solve it? 与错误相关的是什么以及如何解决?

You can fin the answer explained here . 您可以找到此处说明的答案。 What happens is that any requests for unknown text files initially get redirected to index.html, and therefore return with the MIME type of text/html . 发生的情况是,对未知文本文件的任何请求最初都会重定向到index.html,并因此以text/html的MIME类型返回。 To solve this, you need to catch the service-worker file before it goes to the index by default. 为了解决这个问题,您需要在默认情况下在进入索引之前捕获service-worker文件。

暂无
暂无

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

相关问题 FirebaseError browserErrorMessage:“无法注册 ServiceWorker:ServiceWorker 脚本评估失败” - FirebaseError browserErrorMessage: "Failed to register a ServiceWorker: ServiceWorker script evaluation failed" 注册 ServiceWorker 失败 (Next.js) - Failed to register a ServiceWorker (Next.js) 注册 ServiceWorker 失败:脚本的 MIME 类型不受支持 - reactjs - Failed to register a ServiceWorker: The script has an unsupported MIME type - reactjs CRA - 无法注册 ServiceWorker,不支持的 MIME 类型 ('text/html') - CRA - Failed to register a ServiceWorker, unsupported MIME type ('text/html') 注册 ServiceWorker 失败:脚本具有不受支持的 MIME 类型 ('text/html') - Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html') MSW:无法使用脚本为范围注册 ServiceWorker 该脚本具有不受支持的 MIME 类型('text/html') - MSW: Failed to register a ServiceWorker for scope with script The script has an unsupported MIME type ('text/html') 无法为 scope 注册 ServiceWorker - 脚本具有不受支持的 MIME 类型 ('text/html') - Failed to register a ServiceWorker for scope - The script has an unsupported MIME type ('text/html') Service Worker 注册期间出错:DOMException:无法为作用域注册 ServiceWorker。发生 SSL 证书错误 - Error during service worker registration: DOMException: Failed to register a ServiceWorker for scope.An SSL certificate error occurred FirebaseError:由于客户端离线,无法获取文档 - FirebaseError: Failed to get document because the client is offline 注册时的 ServiceWorker MIME 类型错误 ('text/html') (React) - ServiceWorker MIME Type Error ('text/html') on register (React)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM