Browse Source

docker: env

Yi 1 year ago
parent
commit
2a7e89dcab
2 changed files with 8 additions and 7 deletions
  1. 2 0
      Dockerfile
  2. 6 7
      src/utils/request.js

+ 2 - 0
Dockerfile

@@ -11,6 +11,8 @@ RUN npm run build:prod
 
 # 第二阶段构建
 FROM nginx:alpine
+ENV VUE_APP_BASE_API=https://www.baidu.com/
+
 COPY --from=builder /app/tmr-group-admin/dist/ /usr/share/nginx/html/
 COPY --from=builder /app/tmr-group-admin/default.conf.template /etc/nginx/templates/default.conf.template
 EXPOSE 80

+ 6 - 7
src/utils/request.js

@@ -5,16 +5,15 @@ import { getToken } from '@/utils/auth'
 
 //获取当前url
 
-//var aa = window.GLOBAL.SERVICE_URL
-var aa = process.env.VUE_APP_BASE_API
-console.log(aa,'===========aa')
+var URL = process.env.VUE_APP_BASE_API
+console.log(URL,'===========URL')
 //获取当前url
-if(aa.indexOf('/')==0 && aa.length==1){
-  aa= window.location.protocol + "//"+window.location.host+aa
-  console.log(aa,'===========aa22')
+if(URL.indexOf('/')==0 && URL.length==1){
+  URL= window.location.protocol + "//"+window.location.host+URL
+  console.log(URL,'===========URL')
 }
   const service = axios.create({
-    baseURL: aa, // url = base url + request url
+    baseURL: URL, // url = base url + request url
     withCredentials: true, // send cookies when cross-domain requests
     timeout: 60000 ,// request timeout
   })