|
4 | 4 | * For more information, see https://remix.run/file-conventions/entry.server |
5 | 5 | */ |
6 | 6 |
|
7 | | -import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare' |
8 | | -import { RemixServer } from '@remix-run/react' |
| 7 | +import { |
| 8 | + ServerRouter, |
| 9 | + type AppLoadContext, |
| 10 | + type EntryContext |
| 11 | +} from 'react-router' |
9 | 12 | import { isbot } from 'isbot' |
10 | 13 | import { renderToReadableStream } from 'react-dom/server' |
11 | 14 |
|
12 | | -const ABORT_DELAY = 5000 |
| 15 | +export const streamTimeout = 5000 |
13 | 16 |
|
14 | 17 | export default async function handleRequest( |
15 | 18 | request: Request, |
16 | 19 | responseStatusCode: number, |
17 | 20 | responseHeaders: Headers, |
18 | | - remixContext: EntryContext, |
| 21 | + reactRouterContext: EntryContext, |
19 | 22 | // This is ignored so we can keep it in the template for visibility. Feel |
20 | 23 | // free to delete this parameter in your app if you're not using it! |
21 | 24 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
22 | 25 | loadContext: AppLoadContext |
23 | 26 | ) { |
24 | 27 | const controller = new AbortController() |
25 | | - const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY) |
| 28 | + const timeoutId = setTimeout(() => controller.abort(), streamTimeout) |
26 | 29 |
|
27 | 30 | const body = await renderToReadableStream( |
28 | | - <RemixServer |
29 | | - context={remixContext} |
30 | | - url={request.url} |
31 | | - abortDelay={ABORT_DELAY} |
32 | | - />, |
| 31 | + <ServerRouter context={reactRouterContext} url={request.url} />, |
33 | 32 | { |
34 | 33 | signal: controller.signal, |
35 | 34 | onError(error: unknown) { |
|
0 commit comments