diff --git a/server/src/responders/landing-handler.js b/server/src/responders/landing-handler.js --- a/server/src/responders/landing-handler.js +++ b/server/src/responders/landing-handler.js @@ -9,7 +9,7 @@ import { type LandingSSRProps } from '../landing/landing-ssr.react'; import { waitForStream } from '../utils/json-stream'; -import { getLandingURLFacts } from '../utils/urls'; +import { getLandingURLFacts, clientURLFromLocalURL } from '../utils/urls'; import { getMessageForException } from './utils'; async function landingHandler(req: $Request, res: $Response) { @@ -91,15 +91,10 @@ } } -const { basePath, baseRoutePath } = getLandingURLFacts(); +const urlFacts = getLandingURLFacts(); +const { basePath } = urlFacts; const { renderToNodeStream } = ReactDOMServer; -const replaceURLRegex = new RegExp(`^${baseRoutePath}(.*)$`); -const replaceURLModifier = `${basePath}$1`; -function clientURLFromLocalURL(url: string): string { - return url.replace(replaceURLRegex, replaceURLModifier); -} - async function landingResponder(req: $Request, res: $Response) { const [{ jsURL, fontURLs, cssInclude }, LandingSSR] = await Promise.all([ getAssetInfo(), @@ -145,7 +140,7 @@ // We remove trailing slash for `react-router` const routerBasename = basePath.replace(/\/$/, ''); - const publicURL = clientURLFromLocalURL(req.url); + const publicURL = clientURLFromLocalURL(req.url, urlFacts); const reactStream = renderToNodeStream( , ); diff --git a/server/src/utils/urls.js b/server/src/utils/urls.js --- a/server/src/utils/urls.js +++ b/server/src/utils/urls.js @@ -30,9 +30,15 @@ return landingURLFacts; } +function clientURLFromLocalURL(url: string, urlFacts: AppURLFacts): string { + const { basePath } = urlFacts; + return basePath + url; +} + export { getSquadCalURLFacts, getCommAppURLFacts, getLandingURLFacts, getAppURLFactsFromRequestURL, + clientURLFromLocalURL, };