File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 11REACT_APP_DEPLOYMENT_NAME = Source Academy
22
33REACT_APP_BACKEND_URL = http://localhost:4000
4+ REACT_APP_FORWARD_LOAD_BALANCER_COOKIES = FALSE
45REACT_APP_USE_BACKEND = TRUE
56REACT_APP_USE_EMPTY_ASSET_PREFIX = FALSE
67REACT_APP_PLAYGROUND_ONLY = FALSE
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ const storiesBackendUrl = process.env.REACT_APP_STORIES_BACKEND_URL;
2121const cadetLoggerUrl = isTest ? undefined : process . env . REACT_APP_CADET_LOGGER ;
2222const cadetLoggerInterval = parseInt ( process . env . REACT_APP_CADET_LOGGER_INTERVAL || '10000' , 10 ) ;
2323const useBackend = ! isTest && isTrue ( process . env . REACT_APP_USE_BACKEND ) ;
24+ /**
25+ * Whether or not attach cookies to every API call. Useful for load balancers that
26+ * route requests based on cookies (e.g. for sticky sessions).
27+ */
28+ const forwardLoadBalancerCookies = isTrue ( process . env . REACT_APP_FORWARD_LOAD_BALANCER_COOKIES ) ;
2429const useEmptyAssetPrefix = isTrue ( process . env . REACT_APP_USE_EMPTY_ASSET_PREFIX ) ;
2530const defaultSourceChapter = Chapter . SOURCE_4 ;
2631const defaultSourceVariant = Variant . DEFAULT ;
@@ -158,6 +163,7 @@ const Constants = {
158163 storiesBackendUrl,
159164 cadetLoggerUrl,
160165 useBackend,
166+ forwardLoadBalancerCookies,
161167 useEmptyAssetPrefix,
162168 defaultSourceChapter,
163169 defaultSourceVariant,
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ export const request = async (
5151 opts : RequestOptions ,
5252 rawUrl ?: string
5353) : Promise < Response | null > => {
54+ if ( Constants . forwardLoadBalancerCookies ) {
55+ // Always attach cookies to every API call
56+ opts . withCredentials = true ;
57+ }
5458 const fetchOptions = generateApiCallHeadersAndFetchOptions ( method , opts ) ;
5559
5660 try {
You can’t perform that action at this time.
0 commit comments