2023-06-27 00:28:54 +00:00
|
|
|
import { renderToString } from 'react-dom/server'
|
|
|
|
import { RemixServer } from '@remix-run/react'
|
|
|
|
import type { EntryContext } from '@remix-run/react/dist/entry'
|
2023-06-27 00:23:58 +00:00
|
|
|
|
2023-06-27 00:28:54 +00:00
|
|
|
export default function handleRequest (
|
2023-06-27 00:23:58 +00:00
|
|
|
request: Request,
|
|
|
|
responseStatusCode: number,
|
|
|
|
responseHeaders: Headers,
|
|
|
|
remixContext: EntryContext
|
|
|
|
) {
|
|
|
|
let markup = renderToString(
|
|
|
|
<RemixServer context={remixContext} url={request.url} />
|
2023-06-27 00:28:54 +00:00
|
|
|
)
|
2023-06-27 00:23:58 +00:00
|
|
|
|
2023-06-27 00:28:54 +00:00
|
|
|
responseHeaders.set('Content-Type', 'text/html')
|
2023-06-27 00:23:58 +00:00
|
|
|
|
2023-06-27 00:28:54 +00:00
|
|
|
return new Response('<!DOCTYPE html>' + markup, {
|
2023-06-27 00:23:58 +00:00
|
|
|
status: responseStatusCode,
|
|
|
|
headers: responseHeaders
|
2023-06-27 00:28:54 +00:00
|
|
|
})
|
2023-06-27 00:23:58 +00:00
|
|
|
}
|