fix env
This commit is contained in:
1 parent
a3e1a93524
commit
537ef21cf3
6 files changed
+29
-9
No files matched your search
+7
-2
@@ -2,13 +2,18 @@ server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location ~ ^/api/(me|token) {
|
||||
proxy_pass http://auth-backend:8000;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://data-backend:8000/api/;
|
||||
proxy_pass http://data-backend:8000;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
proxy_pass http://data-backend:8000/static/;
|
||||
proxy_pass http://data-backend:8000;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const ENV_LOCAL = 'local';
|
||||
export const ENV_TEST = 'test';
|
||||
export const ENV_PRODUCTION = 'production';
|
||||
@@ -1 +1,2 @@
|
||||
export * from './errorCode';
|
||||
export * from './env';
|
||||
@@ -11,8 +11,6 @@ import './plugins/font-awesome';
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
const env = import.meta.env.VITE_APP_ENV;
|
||||
console.log('env', env);
|
||||
app.use(router);
|
||||
app.use(store);
|
||||
app.use(ElementPlus);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ENV_LOCAL, ENV_TEST } from '@/constants';
|
||||
import { getEnv } from './env';
|
||||
|
||||
/**
|
||||
@@ -6,9 +7,9 @@ import { getEnv } from './env';
|
||||
*/
|
||||
export const getDataBaseUrl = () => {
|
||||
const env = getEnv();
|
||||
if (env === 'local') {
|
||||
if (env === ENV_LOCAL) {
|
||||
return 'https://data.local.zhishuyun.com';
|
||||
} else if (env === 'test') {
|
||||
} else if (env === ENV_TEST) {
|
||||
return 'https://data.test.zhishuyun.com';
|
||||
} else {
|
||||
return 'https://data.zhishuyun.com';
|
||||
@@ -17,9 +18,9 @@ export const getDataBaseUrl = () => {
|
||||
|
||||
export const getAuthBaseUrl = () => {
|
||||
const env = getEnv();
|
||||
if (env === 'local') {
|
||||
if (env === ENV_LOCAL) {
|
||||
return 'https://auth.test.zhishuyun.com';
|
||||
} else if (env === 'test') {
|
||||
} else if (env === ENV_TEST) {
|
||||
return 'https://auth.test.zhishuyun.com';
|
||||
} else {
|
||||
return 'https://auth.zhishuyun.com';
|
||||
|
||||
+13
-1
@@ -1,7 +1,19 @@
|
||||
import { ENV_LOCAL, ENV_PRODUCTION, ENV_TEST } from '@/constants';
|
||||
|
||||
const PATTERN_TEST_ENV = '.test.zhishuyun.com';
|
||||
const PATTERN_LOCAL_ENV = '.lcoal.zhishuyun.com';
|
||||
|
||||
/**
|
||||
* Get env of App, return local, test, production
|
||||
* @returns
|
||||
*/
|
||||
export const getEnv = () => {
|
||||
return import.meta.env.VITE_APP_ENV;
|
||||
const host = window.location.host;
|
||||
if (host.indexOf(PATTERN_LOCAL_ENV) > 0) {
|
||||
return ENV_LOCAL;
|
||||
}
|
||||
if (host.indexOf(PATTERN_TEST_ENV) > 0) {
|
||||
return ENV_TEST;
|
||||
}
|
||||
return ENV_PRODUCTION;
|
||||
};
|
||||
Reference in new issue
Block a user