Index
Index

Reputation: 746

navigator.serviceWorker for development environment

serviceWorker in navigator available only if web page is loaded via https. Is there any way to make it working on development environment using usual http?

if ('serviceWorker' in navigator) {
    console.log('serviceWorker');
}

It does not wok on my development environment.

I'm using firefox/chrome as a browser.

Upvotes: 0

Views: 215

Answers (1)

Dmitriy
Dmitriy

Reputation: 1241

According to MDN: Service workers are restricted to running across HTTPS for security reasons. GitHub is therefore a good place to host experiments, as it supports HTTPS. In order to facilitate local development, localhost is considered a secure origin by browsers as well.

So I would run your dev environment on a localhost port and it should work

Upvotes: 1

Related Questions