-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
* 1. response 302 on redirecting in router 2. heartbeat: 5000 for Node.js 8, via webpack-contrib/webpack-hot-middleware#210 (comment) * mistake * Create setup-dev-server.js * Create entry-server.js
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,6 @@ router.onReady(() => { | |
}) | ||
|
||
// service worker | ||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { | ||
if ('https:' === location.protocol && navigator.serviceWorker) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JounQin
Author
Contributor
|
||
navigator.serviceWorker.register('/service-worker.js') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,15 @@ export default context => { | |
const s = isDev && Date.now() | ||
const { app, router, store } = createApp() | ||
|
||
const { url } = context | ||
const fullPath = router.resolve(url).route.fullPath | ||
|
||
if (fullPath !== url) { | ||
This comment has been minimized.
Sorry, something went wrong.
remoe
|
||
reject({ url: fullPath }) | ||
} | ||
|
||
// set router's location | ||
router.push(context.url) | ||
router.push(url) | ||
|
||
// wait until router has resolved possible async hooks | ||
router.onReady(() => { | ||
|
@@ -26,12 +33,10 @@ export default context => { | |
// A preFetch hook dispatches a store action and returns a Promise, | ||
// which is resolved when the action is complete and store state has been | ||
// updated. | ||
Promise.all(matchedComponents.map(component => { | ||
return component.asyncData && component.asyncData({ | ||
store, | ||
route: router.currentRoute | ||
}) | ||
})).then(() => { | ||
Promise.all(matchedComponents.map(({ asyncData }) => asyncData && asyncData({ | ||
store, | ||
route: router.currentRoute | ||
}))).then(() => { | ||
isDev && console.log(`data pre-fetch: ${Date.now() - s}ms`) | ||
// After all preFetch hooks are resolved, our store is now | ||
// filled with the state needed to render the app. | ||
|
@JounQin How to now use service worker on localhost? Using Build Setup from this repo is not enough. Setting up localhost server with
https
introduce unnecessary complexity.