mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Scaffold Vercel serverless serving for Elysia backend
Add a second tsdown entry (src/server/vercel.ts -> dist/vercel.mjs, no-listen handler bundle), a thin api/index.ts Vercel function that re-exports it, and a vercel.json rewrite routing all paths to the function. Needs real-deploy verification (native-dep tracing, rewrite path preservation).
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Vercel serverless entry for the Elysia backend.
|
||||
//
|
||||
// We do NOT bundle the whole backend graph here (the `@/*` and `next/*` alias
|
||||
// resolution + heavy native deps are handled by tsdown). Instead this thin
|
||||
// function re-exports the already-built handler bundle (`dist/vercel.mjs`,
|
||||
// produced by `tsdown` during `turbo build`), and Vercel's function builder
|
||||
// only has to trace the externalized native deps (prisma, sharp, bcrypt,
|
||||
// oidc-provider, pg) from node_modules.
|
||||
//
|
||||
// All requests are routed here via the `rewrites` rule in vercel.json, so the
|
||||
// Elysia app does its own routing/version-rewrite against the original URL.
|
||||
import app from "../dist/vercel.mjs";
|
||||
|
||||
export const config = {
|
||||
runtime: "nodejs",
|
||||
maxDuration: 60,
|
||||
};
|
||||
|
||||
export default function handler(request: Request): Response | Promise<Response> {
|
||||
return app.handle(request);
|
||||
}
|
||||
@@ -87,7 +87,10 @@ const plugins = [
|
||||
];
|
||||
|
||||
export default defineConfig({
|
||||
entry: [resolve(backendDir, "src/server/server.ts")],
|
||||
entry: [
|
||||
resolve(backendDir, "src/server/server.ts"),
|
||||
resolve(backendDir, "src/server/vercel.ts"),
|
||||
],
|
||||
format: ["esm"],
|
||||
outDir: resolve(backendDir, "dist"),
|
||||
target: "node22",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"$schema": "https://openapi.vercel.sh/vercel.json",
|
||||
"framework": null,
|
||||
"rewrites": [
|
||||
{ "source": "/(.*)", "destination": "/api" }
|
||||
],
|
||||
"crons": [
|
||||
{
|
||||
"path": "/api/latest/internal/email-queue-step",
|
||||
|
||||
Reference in New Issue
Block a user