Skip to content

Commit

Permalink
Streaming SSR: Fix RWJS_EXP_SSR_GRAPHQL_ENDPOINT logic (#9134)
Browse files Browse the repository at this point in the history
Prefer `RWJS_EXP_SSR_GRAPHQL_ENDPOINT` if it's set. Fallback to
`proxiedApiUrl` if not.
  • Loading branch information
Tobbe committed Sep 4, 2023
1 parent 0ff463f commit ae11f69
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/vite/src/streaming/registerGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const registerFwGlobals = () => {
return apiPath
} else {
const proxiedApiUrl =
// NOTE: rwConfig.web.host defaults to "localhost", which is
// troublesome in regards to IPv6/IPv4. So all the more
// reason to set RWJS_EXP_SSR_GRAPHQL_ENDPOINT
'http://' + rwConfig.web.host + ':' + rwConfig.web.port + apiPath

if (
Expand All @@ -52,7 +55,7 @@ export const registerFwGlobals = () => {
console.warn()

console.warn(
'You can override this for by setting RWJS_EXP_SSR_GRAPHQL_ENDPOINT in your environment vars'
'You can override this for SSR by setting RWJS_EXP_SSR_GRAPHQL_ENDPOINT in your environment vars'
)
console.warn()

Expand All @@ -62,7 +65,7 @@ export const registerFwGlobals = () => {
}

return (
proxiedApiUrl || (process.env.RWJS_EXP_SSR_GRAPHQL_ENDPOINT as string)
(process.env.RWJS_EXP_SSR_GRAPHQL_ENDPOINT as string) ?? proxiedApiUrl
)
}
})(),
Expand Down

0 comments on commit ae11f69

Please sign in to comment.