Merge branch 'hotfix/baseurl-env' into 'master'
Hotfix/baseurl env
- Application searches for BASE_URL in window.BASE_URL,
- Not found? Application searches for BASE_URL in process.env.REACT_APP_BASE_URL
- Not found? Application aborts
- Login form post url is now the apiURL/login (without the api version)
- Logout XHR post url is now the apiURL/logout (without the api version)
See merge request theappsmith/internal-tools-client!256
This commit is contained in:
commit
eae4c5e618
|
|
@ -1,19 +1,24 @@
|
||||||
[context.production]
|
[context.production]
|
||||||
[context.production.environment]
|
[context.production.environment]
|
||||||
REACT_APP_ENVIRONMENT = "PRODUCTION"
|
REACT_APP_ENVIRONMENT = "PRODUCTION"
|
||||||
|
REACT_APP_BASE_URL = "https://api.appsmith.com"
|
||||||
|
|
||||||
[context.release]
|
[context.release]
|
||||||
[context.release.environment]
|
[context.release.environment]
|
||||||
REACT_APP_ENVIRONMENT = "STAGING"
|
REACT_APP_ENVIRONMENT = "STAGING"
|
||||||
|
REACT_APP_BASE_URL = "https://release-api.appsmith.com"
|
||||||
|
|
||||||
[context.develop]
|
[context.develop]
|
||||||
[context.develop.environment]
|
[context.develop.environment]
|
||||||
REACT_APP_ENVIRONMENT = "DEVELOPMENT"
|
REACT_APP_ENVIRONMENT = "DEVELOPMENT"
|
||||||
|
REACT_APP_BASE_URL = "https://release-api.appsmith.com"
|
||||||
|
|
||||||
[context.a]
|
[context.a]
|
||||||
[context.a.environment]
|
[context.a.environment]
|
||||||
REACT_APP_ENVIRONMENT = "STAGING"
|
REACT_APP_ENVIRONMENT = "STAGING"
|
||||||
|
REACT_APP_BASE_URL = "https://release-api.appsmith.com"
|
||||||
|
|
||||||
[context.b]
|
[context.b]
|
||||||
[context.b.environment]
|
[context.b.environment]
|
||||||
REACT_APP_ENVIRONMENT = "STAGING"
|
REACT_APP_ENVIRONMENT = "STAGING"
|
||||||
|
REACT_APP_BASE_URL = "https://release-api.appsmith.com"
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,11 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
"start": "REACT_APP_ENVIRONMENT=DEVELOPMENT HOST=dev.appsmith.com craco start",
|
"start": "REACT_APP_BASE_URL=https://release-api.appsmith.com REACT_APP_ENVIRONMENT=DEVELOPMENT HOST=dev.appsmith.com craco start",
|
||||||
"build": "craco --max-old-space-size=2048 build",
|
"build": "craco --max-old-space-size=2048 build",
|
||||||
"test": "CI=true craco test",
|
"test": "CI=true craco test",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"start-prod": "REACT_APP_ENVIRONMENT=PRODUCTION craco start",
|
"start-prod": "REACT_APP_BASE_URL=https://api.appsmith.com REACT_APP_ENVIRONMENT=PRODUCTION craco start",
|
||||||
"storybook": "start-storybook",
|
"storybook": "start-storybook",
|
||||||
"cytest": "REACT_APP_TESTING=TESTING REACT_APP_ENVIRONMENT=DEVELOPMENT craco start & ./node_modules/.bin/cypress open",
|
"cytest": "REACT_APP_TESTING=TESTING REACT_APP_ENVIRONMENT=DEVELOPMENT craco start & ./node_modules/.bin/cypress open",
|
||||||
"build-storybook": "build-storybook -c .storybook -o .storybook-out"
|
"build-storybook": "build-storybook -c .storybook -o .storybook-out"
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,8 @@
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.BASE_URL = "___BASE_URL___";
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
} from "constants/ApiConstants";
|
} from "constants/ApiConstants";
|
||||||
import { ActionApiResponse } from "./ActionAPI";
|
import { ActionApiResponse } from "./ActionAPI";
|
||||||
import { AUTH_LOGIN_URL } from "constants/routes";
|
import { AUTH_LOGIN_URL } from "constants/routes";
|
||||||
const { apiUrl, baseUrl } = getAppsmithConfigs();
|
const { baseUrl, apiUrl } = getAppsmithConfigs();
|
||||||
|
|
||||||
//TODO(abhinav): Refactor this to make more composable.
|
//TODO(abhinav): Refactor this to make more composable.
|
||||||
export const apiRequestConfig = {
|
export const apiRequestConfig = {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { AxiosPromise } from "axios";
|
import { AxiosPromise } from "axios";
|
||||||
import Api from "./Api";
|
import Api from "./Api";
|
||||||
import { ApiResponse } from "./ApiResponses";
|
import { ApiResponse } from "./ApiResponses";
|
||||||
import { getAppsmithConfigs } from "configs";
|
|
||||||
|
|
||||||
export interface LoginUserRequest {
|
export interface LoginUserRequest {
|
||||||
email: string;
|
email: string;
|
||||||
|
|
@ -55,7 +54,7 @@ class UserApi extends Api {
|
||||||
static inviteUserURL = "v1/users/invite";
|
static inviteUserURL = "v1/users/invite";
|
||||||
static verifyInviteTokenURL = `${UserApi.inviteUserURL}/verify`;
|
static verifyInviteTokenURL = `${UserApi.inviteUserURL}/verify`;
|
||||||
static confirmUserInviteURL = `${UserApi.inviteUserURL}/confirm`;
|
static confirmUserInviteURL = `${UserApi.inviteUserURL}/confirm`;
|
||||||
static logoutURL = "/logout";
|
static logoutURL = "v1/logout";
|
||||||
|
|
||||||
static createUser(
|
static createUser(
|
||||||
request: CreateUserRequest,
|
request: CreateUserRequest,
|
||||||
|
|
@ -103,11 +102,7 @@ class UserApi extends Api {
|
||||||
}
|
}
|
||||||
|
|
||||||
static logoutUser(): AxiosPromise<ApiResponse> {
|
static logoutUser(): AxiosPromise<ApiResponse> {
|
||||||
const { baseUrl } = getAppsmithConfigs();
|
return Api.post(UserApi.logoutURL);
|
||||||
return Api.post(UserApi.logoutURL, undefined, undefined, {
|
|
||||||
baseURL: baseUrl,
|
|
||||||
withCredentials: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import { SENTRY_STAGE_CONFIG } from "constants/ThirdPartyConstants";
|
import { SENTRY_STAGE_CONFIG } from "constants/ThirdPartyConstants";
|
||||||
import { STAGE_BASE_URL } from "constants/ApiConstants";
|
|
||||||
import { AppsmithUIConfigs } from "./types";
|
import { AppsmithUIConfigs } from "./types";
|
||||||
|
|
||||||
const devConfig: AppsmithUIConfigs = {
|
const devConfig = (baseUrl: string): AppsmithUIConfigs => ({
|
||||||
sentry: {
|
sentry: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
config: SENTRY_STAGE_CONFIG,
|
config: SENTRY_STAGE_CONFIG,
|
||||||
|
|
@ -14,7 +13,7 @@ const devConfig: AppsmithUIConfigs = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
apiUrl: "/api/",
|
apiUrl: "/api/",
|
||||||
baseUrl: STAGE_BASE_URL,
|
baseUrl,
|
||||||
};
|
});
|
||||||
|
|
||||||
export default devConfig;
|
export default devConfig;
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,35 @@ import prodConfig from "./prod.config";
|
||||||
import stageConfig from "./stage.config";
|
import stageConfig from "./stage.config";
|
||||||
import devConfig from "./dev.config";
|
import devConfig from "./dev.config";
|
||||||
import { AppsmithUIConfigs } from "./types";
|
import { AppsmithUIConfigs } from "./types";
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
BASE_URL: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(Abhinav): See if this is called so many times, that we may need memoization.
|
||||||
export const getAppsmithConfigs = (): AppsmithUIConfigs => {
|
export const getAppsmithConfigs = (): AppsmithUIConfigs => {
|
||||||
|
const WINDOW_BASE_URL: string = window.BASE_URL;
|
||||||
|
const REACT_APP_BASE_URL: string | undefined = process.env.REACT_APP_BASE_URL;
|
||||||
|
|
||||||
|
const BASE_URL =
|
||||||
|
WINDOW_BASE_URL === "___BASE_URL___" ? REACT_APP_BASE_URL : WINDOW_BASE_URL;
|
||||||
|
|
||||||
|
if (!BASE_URL) {
|
||||||
|
throw Error("NO API Endpont defined - aborting");
|
||||||
|
}
|
||||||
switch (process.env.REACT_APP_ENVIRONMENT) {
|
switch (process.env.REACT_APP_ENVIRONMENT) {
|
||||||
case "PRODUCTION":
|
case "PRODUCTION":
|
||||||
return prodConfig;
|
return prodConfig(BASE_URL);
|
||||||
case "STAGING":
|
case "STAGING":
|
||||||
return stageConfig;
|
return stageConfig(BASE_URL);
|
||||||
case "DEVELOPMENT":
|
case "DEVELOPMENT":
|
||||||
return devConfig;
|
return devConfig(BASE_URL);
|
||||||
default:
|
default:
|
||||||
console.log(
|
console.log(
|
||||||
"Unknown environment set: ",
|
"Unknown environment set: ",
|
||||||
process.env.REACT_APP_ENVIRONMENT,
|
process.env.REACT_APP_ENVIRONMENT,
|
||||||
);
|
);
|
||||||
devConfig.apiUrl = "";
|
return devConfig(BASE_URL);
|
||||||
return devConfig;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@ import {
|
||||||
HOTJAR_PROD_HJID,
|
HOTJAR_PROD_HJID,
|
||||||
HOTJAR_PROD_HJSV,
|
HOTJAR_PROD_HJSV,
|
||||||
} from "constants/ThirdPartyConstants";
|
} from "constants/ThirdPartyConstants";
|
||||||
import { PROD_BASE_URL } from "constants/ApiConstants";
|
|
||||||
import { AppsmithUIConfigs } from "./types";
|
import { AppsmithUIConfigs } from "./types";
|
||||||
|
|
||||||
export const prodConfig: AppsmithUIConfigs = {
|
export const prodConfig = (baseUrl: string): AppsmithUIConfigs => ({
|
||||||
sentry: {
|
sentry: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
config: SENTRY_PROD_CONFIG,
|
config: SENTRY_PROD_CONFIG,
|
||||||
|
|
@ -22,7 +21,7 @@ export const prodConfig: AppsmithUIConfigs = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
apiUrl: "/api/",
|
apiUrl: "/api/",
|
||||||
baseUrl: PROD_BASE_URL,
|
baseUrl,
|
||||||
};
|
});
|
||||||
|
|
||||||
export default prodConfig;
|
export default prodConfig;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import { SENTRY_STAGE_CONFIG } from "constants/ThirdPartyConstants";
|
import { SENTRY_STAGE_CONFIG } from "constants/ThirdPartyConstants";
|
||||||
import { STAGE_BASE_URL } from "constants/ApiConstants";
|
|
||||||
import { AppsmithUIConfigs } from "./types";
|
import { AppsmithUIConfigs } from "./types";
|
||||||
|
|
||||||
const stageConfig: AppsmithUIConfigs = {
|
const stageConfig = (baseUrl: string): AppsmithUIConfigs => ({
|
||||||
sentry: {
|
sentry: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
config: SENTRY_STAGE_CONFIG,
|
config: SENTRY_STAGE_CONFIG,
|
||||||
|
|
@ -14,7 +13,7 @@ const stageConfig: AppsmithUIConfigs = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
apiUrl: "/api/",
|
apiUrl: "/api/",
|
||||||
baseUrl: STAGE_BASE_URL,
|
baseUrl,
|
||||||
};
|
});
|
||||||
|
|
||||||
export default stageConfig;
|
export default stageConfig;
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,17 @@ export type ContentType =
|
||||||
| "application/json"
|
| "application/json"
|
||||||
| "application/x-www-form-urlencoded";
|
| "application/x-www-form-urlencoded";
|
||||||
|
|
||||||
export const STAGE_BASE_URL = "https://release-api.appsmith.com";
|
|
||||||
export const PROD_BASE_URL = "https://api.appsmith.com";
|
|
||||||
|
|
||||||
export const REQUEST_TIMEOUT_MS = 10000;
|
export const REQUEST_TIMEOUT_MS = 10000;
|
||||||
|
|
||||||
export const API_REQUEST_HEADERS: APIHeaders = {
|
export const API_REQUEST_HEADERS: APIHeaders = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
};
|
};
|
||||||
export const FORM_REQUEST_HEADERS: APIHeaders = {
|
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
|
||||||
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const OAuthURL = "/oauth2/authorization";
|
export const OAuthURL = "/oauth2/authorization";
|
||||||
export const GoogleOAuthURL = `${OAuthURL}/google`;
|
export const GoogleOAuthURL = `${OAuthURL}/google`;
|
||||||
export const GithubOAuthURL = `${OAuthURL}/github`;
|
export const GithubOAuthURL = `${OAuthURL}/github`;
|
||||||
|
|
||||||
export const LOGIN_SUBMIT_PATH = "/login";
|
export const LOGIN_SUBMIT_PATH = "login";
|
||||||
|
|
||||||
export interface APIException {
|
export interface APIException {
|
||||||
error: number;
|
error: number;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export const Login = (props: LoginFormProps) => {
|
||||||
forgotPasswordURL += `?email=${props.emailValue}`;
|
forgotPasswordURL += `?email=${props.emailValue}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { baseUrl } = getAppsmithConfigs();
|
const { baseUrl, apiUrl } = getAppsmithConfigs();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthCardContainer>
|
<AuthCardContainer>
|
||||||
|
|
@ -108,7 +108,10 @@ export const Login = (props: LoginFormProps) => {
|
||||||
<h5>{LOGIN_PAGE_SUBTITLE}</h5>
|
<h5>{LOGIN_PAGE_SUBTITLE}</h5>
|
||||||
</AuthCardHeader>
|
</AuthCardHeader>
|
||||||
<AuthCardBody>
|
<AuthCardBody>
|
||||||
<SpacedSubmitForm method="POST" action={baseUrl + LOGIN_SUBMIT_PATH}>
|
<SpacedSubmitForm
|
||||||
|
method="POST"
|
||||||
|
action={baseUrl + apiUrl + "v1/" + LOGIN_SUBMIT_PATH}
|
||||||
|
>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
intent={error ? "danger" : "none"}
|
intent={error ? "danger" : "none"}
|
||||||
label={LOGIN_PAGE_EMAIL_INPUT_LABEL}
|
label={LOGIN_PAGE_EMAIL_INPUT_LABEL}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user