Skip to content

Instantly share code, notes, and snippets.

@guxuerui
Last active August 15, 2022 03:02
Show Gist options
  • Save guxuerui/3e661ac806d08add0b40e837580a5288 to your computer and use it in GitHub Desktop.
Save guxuerui/3e661ac806d08add0b40e837580a5288 to your computer and use it in GitHub Desktop.
vite和vue3项目中配置打包后服务请求地址
// 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