diff --git a/pages/_app.tsx b/pages/_app.tsx index 159c42cf698..48333ee72b1 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -27,6 +27,21 @@ import "../src/global-css"; import "../src/test-prep"; import "../src/base.css"; +if (typeof window !== "undefined") { + Promise.prototype.finally = function (callback) { + return this.then( + result => { + callback && callback(); + return result; + }, + result => { + callback && callback(); + throw result; + } + ); + }; +} + interface AuthProps { apiKey?: string; } @@ -36,7 +51,25 @@ function Routing({ Component, pageProps, accessToken }: AppProps & { accessToken const { getFeatureFlag } = useLaunchDarkly(); useEffect(() => { - bootstrapApp(accessToken).then(setStore); + // @ts-ignore + async function fetchAndLog(url: string): any { + const response = await fetch(url); + const json = await response.json(); + console.log(json); + return json; + } + async function init() { + const store = await bootstrapApp(accessToken) + + try { + const response = await fetchAndLog('https://swapi.dev/api/people'); + await fetchAndLog(response.next) + } catch {} + + setStore(store) + } + + init() }, [accessToken]); if (!store) { @@ -156,4 +189,4 @@ App.getInitialProps = (appContext: AppContext) => { return { ...props, ...authProps }; }; -export default App; \ No newline at end of file +export default App; diff --git a/pages/_document.tsx b/pages/_document.tsx index 428e4b410a5..f8a6bc1ca0b 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -31,7 +31,7 @@ const csp = (props: any) => { // localhost:8000 for prod to support the ?dispatch parameter when running // the local backend "http://localhost:* http://*.replay.local ws://*.replay.local ws://localhost:*" - }`, + } https://swapi.dev`, `frame-src replay: https://js.stripe.com https://hooks.stripe.com https://${authHost} https://www.loom.com/`, // Required by some of our external services `script-src 'self' 'unsafe-eval' https://cdn.lr-ingest.io https://cdn.lr-in.com https://js.stripe.com ${hash}`,