UNPKG

fully-react

Version:
29 lines (28 loc) 832 B
// src/winterkit/entry/entry-standalone-with-sirv.ts import { createServer } from "node:http"; import sirv from "sirv"; var handleExports; var sirvHandler; async function init() { handleExports = await import("/virtual:vavite-connect-handler"); sirvHandler = sirv( // @ts-expect-error: This will be defined by the plugin __VAVITE_CLIENT_BUILD_OUTPUT_DIR, handleExports.sirvOptions ); const PORT = Number(process.env.PORT) || 3e3; const HOST = process.env.HOST || "localhost"; createServer( (req, res) => sirvHandler(req, res, () => { handleExports.default(req, res, () => { if (!res.writableEnded) { res.statusCode = 404; res.end(); } }); }) ).listen(PORT, HOST, () => { console.log(`Server listening on http://${HOST}:${PORT}`); }); } init();