Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
REACT_APP_DEPLOYMENT_NAME=Source Academy

REACT_APP_BACKEND_URL=http://localhost:4000
REACT_APP_FORWARD_LOAD_BALANCER_COOKIES=FALSE
REACT_APP_USE_BACKEND=TRUE
REACT_APP_USE_EMPTY_ASSET_PREFIX=FALSE
REACT_APP_PLAYGROUND_ONLY=FALSE
Expand Down
6 changes: 6 additions & 0 deletions src/commons/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const storiesBackendUrl = process.env.REACT_APP_STORIES_BACKEND_URL;
const cadetLoggerUrl = isTest ? undefined : process.env.REACT_APP_CADET_LOGGER;
const cadetLoggerInterval = parseInt(process.env.REACT_APP_CADET_LOGGER_INTERVAL || '10000', 10);
const useBackend = !isTest && isTrue(process.env.REACT_APP_USE_BACKEND);
/**
* Whether or not attach cookies to every API call. Useful for load balancers that
* route requests based on cookies (e.g. for sticky sessions).
*/
const forwardLoadBalancerCookies = isTrue(process.env.REACT_APP_FORWARD_LOAD_BALANCER_COOKIES);
const useEmptyAssetPrefix = isTrue(process.env.REACT_APP_USE_EMPTY_ASSET_PREFIX);
const defaultSourceChapter = Chapter.SOURCE_4;
const defaultSourceVariant = Variant.DEFAULT;
Expand Down Expand Up @@ -158,6 +163,7 @@ const Constants = {
storiesBackendUrl,
cadetLoggerUrl,
useBackend,
forwardLoadBalancerCookies,
useEmptyAssetPrefix,
defaultSourceChapter,
defaultSourceVariant,
Expand Down
4 changes: 4 additions & 0 deletions src/commons/utils/RequestHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const request = async (
opts: RequestOptions,
rawUrl?: string
): Promise<Response | null> => {
if (Constants.forwardLoadBalancerCookies) {
// Always attach cookies to every API call
opts.withCredentials = true;
}
const fetchOptions = generateApiCallHeadersAndFetchOptions(method, opts);

try {
Expand Down
Loading