博览会:如何在通过localhost访问时修复开发中的Web推送通知以及如何修复localhost服务工作者?

问题描述

我正在使用Expo SDK Version: 36生成PWA。

  • curl http://$LOCAL_IP:19006/expo-service-worker.js:确定200
  • curl http://localhost:19006/expo-service-worker.js:失败=> 不提供服务 expo-service-worker.js 它提供静态资产 index.html

enter image description here

它在控制台中导致以下错误

Failed to register service-worker DOMException: Failed to register a ServiceWorker for scope ('http://localhost:19006/') with script ('http://localhost:19006/expo-service-worker.js'): The script has an unsupported MIME type ('text/html').

文件expo-service-worker.js未被投放,这在必须实施Web推送通知时会出现问题,因为当站点未提供localhost时,只有HTTPS在没有文件推送的情况下可以工作。

相关问题:

我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)