forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-ssr.js
32 lines (29 loc) · 1.06 KB
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react'
import { WrapPagesWithLocaleContext } from './src/components/localization'
import './src/components/localization/config'
import GlobalProvider from './src/store/global-provider'
export const wrapRootElement = ({ element }) => {
return <GlobalProvider>{element}</GlobalProvider>
}
export const wrapPageElement = WrapPagesWithLocaleContext
export const onRenderBody = ({ setHeadComponents }) => {
setHeadComponents([
<script
key="partytown-vanilla-config"
dangerouslySetInnerHTML={{
__html: `partytown = {
resolveUrl(url, location) {
// Use a secure connection
if (url?.protocol === 'http:') {
url = new URL(url.href.replace('http', 'https'))
}
// Point to our proxied URL
const proxyUrl = new URL(location.origin + '/__third-party-proxy')
proxyUrl.searchParams.append('url', url)
return proxyUrl
}
}`,
}}
/>,
])
}