Git Product home page Git Product logo

Comments (7)

devCrossNet avatar devCrossNet commented on June 15, 2024 1

did you check the response? usually, it's an indicator that you entered a wrong path and the web-server responded with the index.html

from serviceworker-webpack-plugin.

sibelius avatar sibelius commented on June 15, 2024

it is not finding my service worker file: http://localhost:7001/firebase-messaging-sw.js

how can I expose it on webpack 4?

from serviceworker-webpack-plugin.

devCrossNet avatar devCrossNet commented on June 15, 2024

if you have a look at the readme here: https://github.com/oliviertassinari/serviceworker-webpack-plugin#api

it is mentioned that the default filename of the service-worker is sw.js so you can either rename your firebase-messaging-sw.js to sw.js or set the filename option to firebase-messaging-sw.js

I hope that helps.

from serviceworker-webpack-plugin.

sibelius avatar sibelius commented on June 15, 2024

I've used filename, tks

from serviceworker-webpack-plugin.

rahul7p avatar rahul7p commented on June 15, 2024

I am facing same issue in vuejs

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

from serviceworker-webpack-plugin.

sibelius avatar sibelius commented on June 15, 2024

I recommend using workbox webpack, it solves the same problem with more tools

from serviceworker-webpack-plugin.

mend3 avatar mend3 commented on June 15, 2024

I've got this error using webpack 4 and serviceworker-webpack-plugin alpha 2

The script has an unsupported MIME type ('text/html').
Failed to load resource: net::ERR_INSECURE_RESPONSE

{
  "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'). (messaging/failed-serviceworker-registration).",
  "browserErrorMessage": "Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html')."
}

Got this working by using middleware that works when not in production mode:

app.use(({ url }: Request, res: Response, next: NextFunction) =>
      url.match(/ngsw-worker.js/) && NODE_ENV !== 'production' ? res.status(200) : next())

Just send status OK to response and that's all.
Got it working on ng serve|npm start|nodemon|pm2

from serviceworker-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.