diff --git a/server/csp.js b/server/csp.js index 5d24c602..c13ff44c 100644 --- a/server/csp.js +++ b/server/csp.js @@ -7,6 +7,7 @@ const unsafeEval = "'unsafe-eval'"; const data = 'data:'; const blob = 'blob:'; const devImagesMaybe = dev ? ['*.localhost:8000'] : []; +const baseUrl = process.env.REACT_APP_SHARETRIBE_SDK_BASE_URL || 'https://flex-api.sharetribe.com'; // Default CSP whitelist. // @@ -18,7 +19,7 @@ const defaultDirectives = { childSrc: [blob], connectSrc: [ self, - process.env.REACT_APP_SHARETRIBE_SDK_BASE_URL, + baseUrl, 'maps.googleapis.com', '*.tiles.mapbox.com', 'api.mapbox.com', diff --git a/server/index.js b/server/index.js index ae4992e0..f45d5f7b 100644 --- a/server/index.js +++ b/server/index.js @@ -167,10 +167,11 @@ app.get('*', (req, res) => { secure: USING_SSL, }); + const baseUrl = BASE_URL ? { baseUrl: BASE_URL } : {}; + const sdk = sharetribeSdk.createInstance({ transitVerbose: TRANSIT_VERBOSE, clientId: CLIENT_ID, - baseUrl: BASE_URL, httpAgent: httpAgent, httpsAgent: httpsAgent, tokenStore, @@ -182,6 +183,7 @@ app.get('*', (req, res) => { reader: v => new Decimal(v.value), }, ], + ...baseUrl, }); // Until we have a better plan for caching dynamic content and we diff --git a/src/index.js b/src/index.js index 9c0a3d05..3f856b08 100644 --- a/src/index.js +++ b/src/index.js @@ -77,13 +77,14 @@ if (typeof window !== 'undefined') { // set up logger with Sentry DSN client key and environment log.setup(); + const baseUrl = config.sdk.baseUrl ? { baseUrl: config.sdk.baseUrl } : {}; + // eslint-disable-next-line no-underscore-dangle const preloadedState = window.__PRELOADED_STATE__ || '{}'; const initialState = JSON.parse(preloadedState, sdkTypes.reviver); const sdk = createInstance({ transitVerbose: config.sdk.transitVerbose, clientId: config.sdk.clientId, - baseUrl: config.sdk.baseUrl, secure: config.usingSSL, typeHandlers: [ { @@ -93,6 +94,7 @@ if (typeof window !== 'undefined') { reader: v => new Decimal(v.value), }, ], + ...baseUrl, }); const analyticsHandlers = setupAnalyticsHandlers(); const store = configureStore(initialState, sdk, analyticsHandlers);