1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Add a way to disable running service workers. (#1167)

This commit is contained in:
Arunoda Susiripala 2017-02-16 05:43:27 +05:30 committed by Guillermo Rauch
parent 2c9c84e143
commit d8af41d690

View file

@ -10,6 +10,16 @@ import { loadGetInitialProps, getLocationOrigin } from '../utils'
// Add "fetch" polyfill for older browsers
if (typeof window !== 'undefined') {
require('whatwg-fetch')
// Unregister if there's an exisiting service worker.
// This is because we ship a service worker in previous version.
// We don't use it and having a already running worker might cause issues.
// (We can remove this in future releases)
navigator.serviceWorker.getRegistrations()
.then((registrations) => {
for (let registration of registrations) {
registration.unregister()
}
})
}
export default class Router extends EventEmitter {