@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

main
tsx 36 lines 934 Bytes
Raw
1 import {
2 createTemporaryReferenceSet,
3 decodeAction,
4 decodeFormState,
5 decodeReply,
6 loadServerAction,
7 renderToReadableStream,
8 } from "@vitejs/plugin-rsc/rsc";
9 import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
10 import { routes } from "../app/routes";
11
12 export function fetchServer(request: Request) {
13 return matchRSCServerRequest({
14 // Provide the React Server touchpoints.
15 createTemporaryReferenceSet,
16 decodeAction,
17 decodeFormState,
18 decodeReply,
19 loadServerAction,
20 // The incoming request.
21 request,
22 // The app routes.
23 routes,
24 // Encode the match with the React Server implementation.
25 generateResponse(match, options) {
26 return new Response(renderToReadableStream(match.payload, options), {
27 status: match.statusCode,
28 headers: match.headers,
29 });
30 },
31 });
32 }
33
34 if (import.meta.hot) {
35 import.meta.hot.accept();
36 }