Last active
August 15, 2022 03:02
-
-
Save guxuerui/3e661ac806d08add0b40e837580a5288 to your computer and use it in GitHub Desktop.
vite和vue3项目中配置打包后服务请求地址
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in public/config.js | |
window.g = { | |
protocol: 'http', | |
address: '192.168.20.229', | |
port: 18000, | |
timeout: 12 * 1000 | |
} | |
// in http/index.ts | |
const BASE_URL = `${window.g.protocol}://${window.g.address}:${window.g.port}` | |
const TIME_OUT = +`${window.g.timeout}` | |
const http = axios.create({ | |
baseURL: BASE_URL, | |
timeout: TIME_OUT, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment