entry.server.tsx 570 B

1234567891011121314151617181920
  1. import React from 'react';
  2. import {renderToString} from 'react-dom/server';
  3. import type {EntryContext} from 'remix';
  4. import {RemixServer} from 'remix';
  5. export default function handleRequest(
  6. request: Request,
  7. responseStatusCode: number,
  8. responseHeaders: Headers,
  9. remixContext: EntryContext
  10. ) {
  11. const markup = renderToString(<RemixServer context={remixContext} url={request.url} />);
  12. responseHeaders.set('Content-Type', 'text/html');
  13. return new Response('<!DOCTYPE html>' + markup, {
  14. status: responseStatusCode,
  15. headers: responseHeaders,
  16. });
  17. }