Skip to content

Commit e7c4a24

Browse files
fix: comparing host with origin hostname (#275)
This fixes the problem of comparing host with origin #274
1 parent c52af29 commit e7c4a24

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react-server/server/render-rsc.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export async function render(Component, props = {}, options = {}) {
8080
revalidate$();
8181

8282
const origin = context.request.headers.get("origin");
83-
const protocol = origin && new URL(origin).protocol;
83+
const originURL = origin ? new URL(origin) : null;
84+
const originHostname = originURL?.hostname;
85+
const protocol = originURL?.protocol;
8486
const host = context.request.headers.get("host");
8587
const renderContext = getContext(RENDER_CONTEXT);
8688
const remote = renderContext.flags.isRemote;
@@ -332,7 +334,7 @@ export async function render(Component, props = {}, options = {}) {
332334
? (link) => `/${config.base}/${link?.id || link}`.replace(/\/+/g, "/")
333335
: (link) => link?.id || link;
334336
const linkHref =
335-
remote || (origin && host !== origin)
337+
remote || (origin && host !== originHostname)
336338
? (link) => `${protocol}//${host}${configBaseHref(link)}`
337339
: configBaseHref;
338340
const Styles = () => {
@@ -362,7 +364,7 @@ export async function render(Component, props = {}, options = {}) {
362364

363365
const ModulePreloads =
364366
configModulePreload !== false &&
365-
!(remote || (origin && host !== origin))
367+
!(remote || (origin && host !== originHostname))
366368
? () => {
367369
const modules = getContext(CLIENT_MODULES_CONTEXT);
368370
return (

0 commit comments

Comments
 (0)