-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit a8d7f3f. Due to remix-run/remix#2947
- Loading branch information
Showing
8 changed files
with
12 additions
and
70 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { hydrateRoot } from 'react-dom/client'; | ||
import { hydrate } from 'react-dom'; | ||
import { RemixBrowser } from '@remix-run/react'; | ||
|
||
hydrateRoot(document, <RemixBrowser />); | ||
hydrate(<RemixBrowser />, document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,21 @@ | ||
import { renderToReadableStream } from 'react-dom/server'; | ||
import { renderToString } from 'react-dom/server'; | ||
import type { EntryContext } from '@remix-run/cloudflare'; | ||
import { RemixServer } from '@remix-run/react'; | ||
import isbot from 'isbot'; | ||
|
||
export default async function handleRequest( | ||
export default function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext | ||
) { | ||
const controller = new AbortController(); | ||
const markup = renderToString( | ||
<RemixServer context={remixContext} url={request.url} /> | ||
); | ||
|
||
try { | ||
const stream = await renderToReadableStream( | ||
<RemixServer context={remixContext} url={request.url} />, | ||
{ | ||
signal: controller.signal, | ||
onError: error => { | ||
responseStatusCode = 500; | ||
console.error(error); | ||
}, | ||
} | ||
); | ||
responseHeaders.set('Content-Type', 'text/html'); | ||
|
||
if (isbot(request.headers.get('user-agent'))) { | ||
await stream.allReady; | ||
} | ||
|
||
responseHeaders.set('Content-Type', 'text/html'); | ||
|
||
return new Response(stream, { | ||
status: responseStatusCode, | ||
headers: responseHeaders, | ||
}); | ||
} catch (e) { | ||
return new Response('<!doctype html><p>Loading...</p>', { | ||
status: 500, | ||
headers: { 'Content-Type': 'text/html' }, | ||
}); | ||
} | ||
return new Response('<!DOCTYPE html>' + markup, { | ||
status: responseStatusCode, | ||
headers: responseHeaders, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4379,11 +4379,6 @@ [email protected], isarray@~1.0.0: | |
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" | ||
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= | ||
|
||
isbot@^3.4.6: | ||
version "3.4.6" | ||
resolved "https://registry.yarnpkg.com/isbot/-/isbot-3.4.6.tgz#e3dd70034b6a6fad043753de71cd96929a678015" | ||
integrity sha512-EEi3SVCPB4WHtMBaAYzYLgCP7yG9qixseYCf3IG0Yc+howLia+XFPLTT1437rzeViLeDInKOXOdFhs9Fa/xgWQ== | ||
|
||
isexe@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" | ||
|