|
@@ -1,24 +1,23 @@
|
|
|
import Vue from 'vue'
|
|
|
import Axios from 'axios'
|
|
|
|
|
|
-export function axiosHttp(store) {
|
|
|
+export function axiosHttp(store, req) {
|
|
|
const service = Axios.create({
|
|
|
withCredentials: true,
|
|
|
baseUrl: '/'
|
|
|
})
|
|
|
service.interceptors.request.use(config => {
|
|
|
+
|
|
|
if (process.server) {
|
|
|
+ const cookie = req.headers['cookie']
|
|
|
+ store.commit('option/SET_COOKIES', cookie)
|
|
|
if (config.url.indexOf('.') === -1) {
|
|
|
config.url = process.env.baseUrl + config.url
|
|
|
}
|
|
|
+ config.headers.cookie = store.state.option.cookies + '; ' + store.state.option.sessionId
|
|
|
+ config.headers['User-Agent'] = store.state.option.userAgent
|
|
|
}
|
|
|
- console.log(config.url)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
return config
|
|
|
}, error => {
|
|
|
return Promise.reject(error)
|
|
@@ -49,6 +48,6 @@ export function axiosHttp(store) {
|
|
|
}
|
|
|
|
|
|
export default function ({ isServer, store, req }) {
|
|
|
- axiosHttp(store)
|
|
|
+ axiosHttp(store, req)
|
|
|
}
|
|
|
|