Skip to content

Commit

Permalink
fixed base url issue in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Nov 5, 2021
1 parent 8a89eac commit e2bea31
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crawlab-ui",
"version": "0.6.0-beta.202111032108",
"version": "0.6.0-beta.202111052136",
"private": false,
"author": {
"name": "Marvin Zhang",
Expand Down
4 changes: 4 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import FormItem from './form/FormItem.vue';
import FormReadonlyValue from './form/FormReadonlyValue.vue';
import FormTable from './form/FormTable.vue';
import FormTableField from './form/FormTableField.vue';
import GitFileStatus from './git/GitFileStatus.vue';
import GitForm from './git/GitForm.vue';
import AtomMaterialIcon from './icon/AtomMaterialIcon.vue';
import Icon from './icon/Icon.vue';
import MenuItemIcon from './icon/MenuItemIcon.vue';
Expand Down Expand Up @@ -141,6 +143,8 @@ export {
FormReadonlyValue as ClFormReadonlyValue,
FormTable as ClFormTable,
FormTableField as ClFormTableField,
GitFileStatus as ClGitFileStatus,
GitForm as ClGitForm,
AtomMaterialIcon as ClAtomMaterialIcon,
Icon as ClIcon,
MenuItemIcon as ClMenuItemIcon,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
interface Window {
VUE_APP_API_BASE_URL?: string;
initCanvas?: Function;
resetCanvas?: Function;
_hmt?: Array;
Expand Down
9 changes: 3 additions & 6 deletions src/services/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ export const initRequest = (router?: Router) => {
console.error(err);
}
});
}
};

const useRequest = () => {
const baseUrl = getRequestBaseUrl();

const getHeaders = (): any => {
// headers
const headers = {} as any;
Expand All @@ -46,7 +44,7 @@ const useRequest = () => {

const request = async <R = any>(opts: AxiosRequestConfig): Promise<R> => {
// base url
const baseURL = baseUrl;
const baseURL = getRequestBaseUrl();

// headers
const headers = getHeaders();
Expand Down Expand Up @@ -145,7 +143,7 @@ const useRequest = () => {

const requestRaw = async <R = any>(opts: AxiosRequestConfig): Promise<AxiosResponse> => {
// base url
const baseURL = baseUrl;
const baseURL = getRequestBaseUrl();

// headers
const headers = getHeaders();
Expand All @@ -170,7 +168,6 @@ const useRequest = () => {

return {
// public variables and methods
baseUrl,
request,
get,
post,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const getRequestBaseUrl = (): string => {
return process.env.VUE_APP_API_BASE_URL || 'http://localhost:8000';
return window.VUE_APP_API_BASE_URL || process.env.VUE_APP_API_BASE_URL || 'http://localhost:8000';
};

export const getEmptyResponseWithListData = <T = any>(): ResponseWithListData<T> => {
Expand Down

0 comments on commit e2bea31

Please sign in to comment.