|
|
@@ -92,7 +92,10 @@ const setupProgress = (axios) => {
|
|
|
set: () => { }
|
|
|
}
|
|
|
|
|
|
- const $loading = () => (window.$nuxt && window.$nuxt.$loading && window.$nuxt.$loading.set) ? window.$nuxt.$loading : noopLoading
|
|
|
+ const $loading = () => {
|
|
|
+ const $nuxt = typeof window !== 'undefined' && window['$nuxt']
|
|
|
+ return ($nuxt && $nuxt.$loading && $nuxt.$loading.set) ? $nuxt.$loading : noopLoading
|
|
|
+ }
|
|
|
|
|
|
let currentRequests = 0
|
|
|
|
|
|
@@ -170,14 +173,13 @@ export default (ctx, inject) => {
|
|
|
}
|
|
|
|
|
|
// Proxy SSR request headers headers
|
|
|
- axiosOptions.headers.common = (ctx.req && ctx.req.headers) ? Object.assign({}, ctx.req.headers) : {}
|
|
|
- delete axiosOptions.headers.common['accept']
|
|
|
- delete axiosOptions.headers.common['host']
|
|
|
- delete axiosOptions.headers.common['cf-ray']
|
|
|
- delete axiosOptions.headers.common['cf-connecting-ip']
|
|
|
- delete axiosOptions.headers.common['content-length']
|
|
|
- delete axiosOptions.headers.common['content-md5']
|
|
|
- delete axiosOptions.headers.common['content-type']
|
|
|
+ if (process.server && ctx.req && ctx.req.headers) {
|
|
|
+ const reqHeaders = { ...ctx.req.headers }
|
|
|
+ for (let h of ["accept","host","cf-ray","cf-connecting-ip","content-length","content-md5","content-type"]) {
|
|
|
+ delete reqHeaders[h]
|
|
|
+ }
|
|
|
+ axiosOptions.headers.common = { ...reqHeaders, ...axiosOptions.headers.common }
|
|
|
+ }
|
|
|
|
|
|
if (process.server) {
|
|
|
// Don't accept brotli encoding because Node can't parse it
|