diff --git a/.vscode/launch.json b/.vscode/launch.json index d6c413a8cce6a453536eb843f080c839657ec2b4..60bb23d7775375aede4b3a2e2cf3d965b0487a35 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "type": "pwa-chrome", "request": "launch", "name": "Launch Chrome against localhost", - "url": "http://localhost:3000", + "url": "http://localhost:3001", "webRoot": "${workspaceFolder}" } ] diff --git a/src/utils/request.ts b/src/utils/request.ts index 2bc3d418714b246714fc05fdf7752c1607a9563e..8eba8f5fce223b2c487233cb78ba1efc8971676a 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,6 +1,7 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios' import { toTuofeng } from './index' -import { Page } from '../types/page' +import { Page } from '@/types/page' +import { useLoginStore } from '@/store/modules/login' export interface QuickResponseData { status: number @@ -21,9 +22,10 @@ const quickRequest: AxiosInstance = axios.create({ // 请求拦截器 quickRequest.interceptors.request.use( (config) => { + const loginStore = useLoginStore() console.log('request', config) - // const token = '' - // config.headers.token = `Bearer ${token}` + const token = loginStore.getToken + config.headers.authorization = `Bearer ${token}` return config }, (error) => { diff --git a/vite.config.ts b/vite.config.ts index 366c87b713cd5df50f35e6362447a46b424df44c..e864dcd80031429b4dd398e2d343675c7197aa41 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -47,8 +47,8 @@ export default ({ command, mode }) => { port: VITE_PORT, proxy: { [VITE_APP_BASE_URL]: { - // target: 'http://localhost:3002/', // 代理的目标地址 - target: 'http://110.42.130.88:3102/', // 代理的目标地址 + // target: 'http://localhost:3002/', // 代理的目标地址-本地 + target: 'http://110.42.130.88:3102/', // 代理的目标地址-线上 changeOrigin: false, // 开发模式,默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址 secure: false, // 是否https接口 ws: false, // 是否代理websockets