File tree Expand file tree Collapse file tree 7 files changed +24
-9
lines changed
client/packages/lowcoder/src Expand file tree Collapse file tree 7 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,18 @@ export const API_REQUEST_HEADERS: RawAxiosRequestHeaders = {
52
52
"Content-Type" : "application/json" ,
53
53
} ;
54
54
55
- export const SERVER_HOST = `${ REACT_APP_API_SERVICE_URL ?? "" } /__LOWCODER_BASEPATH_PLACEHOLDER__` ;
55
+ const nodeEnv = process . env . NODE_ENV ?? "development" ;
56
+ const isDev = nodeEnv === "development" ;
57
+ const DEV_SERVER_HOST = `${ REACT_APP_API_SERVICE_URL ?? "" } /` ;
58
+ const PROD_SERVER_HOST = `${ REACT_APP_API_SERVICE_URL ?? "" } /__LOWCODER_BASEPATH_PLACEHOLDER__` ;
59
+
60
+ const createUrlByEnv = ( baseUrl : string = "" ) => {
61
+ const nodeEnv = process . env . NODE_ENV ?? "development" ;
62
+ const isDev = nodeEnv === "development" ;
63
+ return isDev ? `${ baseUrl } /` : `${ baseUrl } /__LOWCODER_BASEPATH_PLACEHOLDER__` ;
64
+ }
65
+
66
+ export const SERVER_HOST = createUrlByEnv ( REACT_APP_API_SERVICE_URL ) ;
56
67
export const ASSETS_URI = ( id : string ) => `${ SERVER_HOST } /api/v1/assets/${ id } ` ;
57
68
export const USER_HEAD_UPLOAD_URL = `${ SERVER_HOST } /api/v1/users/photo` ;
58
69
export const ORG_ICON_UPLOAD_URL = ( orgId : string ) => `${ SERVER_HOST } /api/v1/organizations/${ orgId } /logo` ;
Original file line number Diff line number Diff line change 1
1
// export const SERVER_HOST = `${REACT_APP_NODE_SERVICE_URL ?? ""}`;
2
2
// export const NPM_REGISTRY_URL = `${SERVER_HOST}/node-service/api/npm/registry`;
3
3
// export const NPM_PLUGIN_ASSETS_BASE_URL = `${SERVER_HOST}/node-service/api/npm/package`;
4
+
5
+ import { SERVER_HOST } from "./apiConstants" ;
6
+
4
7
export const ASSETS_BASE_URL = `api/npm/package` ;
5
- export const SERVER_HOST = `${ REACT_APP_API_SERVICE_URL ?? "" } ` ;
6
8
export const NPM_REGISTRY_URL = `${ SERVER_HOST } /api/npm/registry` ;
7
9
export const NPM_PLUGIN_ASSETS_BASE_URL = `${ SERVER_HOST } /api/npm/package` ;
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export function SubscriptionCancel() {
43
43
const session_id = query . get ( "session_id" ) ;
44
44
45
45
useEffect ( ( ) => {
46
- window . location . replace ( SUBSCRIPTION_SETTING ) ;
46
+ history . replace ( SUBSCRIPTION_SETTING ) ;
47
47
} , [ ] ) ;
48
48
49
49
return (
Original file line number Diff line number Diff line change @@ -83,14 +83,14 @@ export function authRespValidate(
83
83
if ( doValidResponse ( resp ) ) {
84
84
onAuthSuccess ?.( ) ;
85
85
sessionStorage . setItem ( "_just_logged_in_" , "true" ) ;
86
- history . replace ( replaceUrl . replace ( baseUrl , '' ) ) ;
86
+ window . location . replace ( replaceUrl . replace ( baseUrl , '' ) ) ;
87
87
} else if (
88
88
resp . data . code === SERVER_ERROR_CODES . EXCEED_MAX_USER_ORG_COUNT ||
89
89
resp . data . code === SERVER_ERROR_CODES . ALREADY_IN_ORGANIZATION
90
90
) {
91
91
messageInstance . error ( resp . data . message ) ;
92
92
// redirect after displaying the message for a second
93
- setTimeout ( ( ) => window . location . replace ( replaceUrl ) , 1500 ) ;
93
+ setTimeout ( ( ) => history . replace ( replaceUrl ) , 1500 ) ;
94
94
} else {
95
95
throw Error ( resp . data . message ) ;
96
96
}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import { User } from "constants/userConstants";
33
33
import { getUserSaga } from "redux/sagas/userSagas" ;
34
34
import { GetMyOrgsResponse } from "@lowcoder-ee/api/userApi" ;
35
35
import UserApi from "@lowcoder-ee/api/userApi" ;
36
+ import history from "@lowcoder-ee/util/history" ;
36
37
37
38
export function * updateGroupSaga ( action : ReduxAction < UpdateGroupActionPayload > ) {
38
39
try {
@@ -248,7 +249,7 @@ export function* switchOrgSaga(action: ReduxAction<{ orgId: string }>) {
248
249
const response : AxiosResponse < ApiResponse > = yield call ( OrgApi . switchOrg , action . payload . orgId ) ;
249
250
const isValidResponse : boolean = validateResponse ( response ) ;
250
251
if ( isValidResponse ) {
251
- window . location . replace ( BASE_URL ) ;
252
+ history . replace ( BASE_URL ) ;
252
253
}
253
254
} catch ( error : any ) {
254
255
messageInstance . error ( error . message ) ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import { AuthSearchParams } from "constants/authConstants";
26
26
import { saveAuthSearchParams } from "pages/userAuth/authUtils" ;
27
27
import { initTranslator } from "i18n" ;
28
28
import { fetchWorkspacesAction } from "../reduxActions/orgActions" ;
29
+ import history from "@lowcoder-ee/util/history" ;
29
30
30
31
function validResponseData ( response : AxiosResponse < ApiResponse > ) {
31
32
return response && response . data && response . data . data ;
@@ -45,7 +46,7 @@ export function* getUserSaga() {
45
46
const redirectUrl = new URL ( redirectUri ) ;
46
47
redirectUrl . pathname = currentUrl . pathname ;
47
48
redirectUrl . search = currentUrl . search ;
48
- window . location . replace ( redirectUrl ) ;
49
+ history . replace ( redirectUrl ) ;
49
50
return ;
50
51
}
51
52
if ( validateResponse ( response ) ) {
@@ -163,7 +164,7 @@ export function* logoutSaga(action: LogoutActionType) {
163
164
if ( isValidResponse ) {
164
165
yield put ( logoutSuccess ( ) ) ;
165
166
localStorage . clear ( ) ;
166
- window . location . replace ( redirectURL ) ;
167
+ history . replace ( redirectURL ) ;
167
168
}
168
169
} catch ( error ) {
169
170
log . error ( error ) ;
Original file line number Diff line number Diff line change 1
1
import { createBrowserHistory } from "history" ;
2
- export default createBrowserHistory ( { basename : "__LOWCODER_BASEPATH_PLACEHOLDER__" } ) ;
2
+ export default createBrowserHistory ( { basename : "/ __LOWCODER_BASEPATH_PLACEHOLDER__" } ) ;
You can’t perform that action at this time.
0 commit comments