mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
22 lines
961 B
JavaScript
22 lines
961 B
JavaScript
// e2e/differ server entry: the production build behind a shim that supplies
|
|
// the proxy protocol header. adapter-node bakes `paths.origin` at build time
|
|
// and otherwise guesses `https://` from a bare request, but one e2e build
|
|
// serves many worker ports over plain http — deriving the origin per request
|
|
// from `x-forwarded-proto` + Host keeps remote-function CSRF checks passing.
|
|
// Run with PROTOCOL_HEADER=x-forwarded-proto (set by the tooling).
|
|
import { createServer } from "node:http";
|
|
|
|
// the build output only exists after `pnpm run build`; the indirection keeps
|
|
// svelte-check from following (and type-checking) the generated chunks
|
|
const buildDir = "../build";
|
|
const { handler } = await import(`${buildDir}/handler.js`);
|
|
|
|
const port = Number(process.env.PORT ?? 3000);
|
|
|
|
createServer((req, res) => {
|
|
req.headers["x-forwarded-proto"] = "http";
|
|
handler(req, res);
|
|
}).listen(port, () => {
|
|
console.log(`Listening on http://0.0.0.0:${port}`);
|
|
});
|