Browse Source

管理后台-权限管理接口域名

panyong 3 years ago
parent
commit
f3a76d0ed2
2 changed files with 5 additions and 4 deletions
  1. 2 2
      htmldev/manage/config/dev.env.js
  2. 3 2
      htmldev/manage/src/api/index.js

+ 2 - 2
htmldev/manage/config/dev.env.js

@@ -4,6 +4,6 @@ const prodEnv = require('./prod.env')
 
 module.exports = merge(prodEnv, {
   NODE_ENV: '"development"',
-  API_AUTH: '"http://tingbang-auth.codedreamit.com"',
-  API_DOMAIN: '"http://tingbang-admin.codedreamit.com"'
+  API_AUTH: '"http://tingbang-auth.codedreamit.com"', // 权限级域名
+  API_DOMAIN: '"http://tingbang-admin.codedreamit.com"' // 业务级域名
 })

+ 3 - 2
htmldev/manage/src/api/index.js

@@ -6,11 +6,12 @@ import { getToken } from '@/utils/auth'
 import { envDomain } from '@/utils/.env.domain'
 
 // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
-
-axios.defaults.baseURL = process.env.VUE_APP_ISPROXY * 1 ? '' : envDomain.API_AUTH
+// axios.defaults.withCredentials = false
 axios.defaults.timeout = 20000
 
 axios.interceptors.request.use(config => {
+    // 设置请求域名
+    config.baseURL = process.env.VUE_APP_ISPROXY * 1 ? '' : /\/api\/auth/.test(config.url) ? envDomain.API_AUTH : envDomain.API_DOMAIN
     if (getToken()) {
       config.headers['token'] = getToken()
     }