Make SQLite database self-create on serverless hosts

Vercel's serverless functions only allow writes to /tmp, and it starts
empty on every cold start. Point the database there in production and
create the User table on first request if it doesn't exist yet, so the
app can be deployed for a live preview without manual database setup.

Note: this is a demo-friendly stand-in — data does not persist across
cold starts on Vercel. A real persistent database is a later phase.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VL5YUEf2B9LG4xdVUQwcSg
This commit is contained in:
Claude committed 2026-09-25 11:43:08 +00:00
1 parent 4e8a2d9037
commit 7b4f05daab
7 files changed
+63 -6

No files matched your search

+3 -1
View File
@@ -1,7 +1,7 @@
import { NextResponse } from "next/server";
import bcrypt from "bcryptjs";
import { z } from "zod";
import { prisma } from "@/lib/prisma";
import { prisma, ensureDb } from "@/lib/prisma";
const signupSchema = z.object({
name: z.string().trim().min(1, "Name is required").max(80),
@@ -11,6 +11,8 @@ const signupSchema = z.object({
});
export async function POST(request: Request) {
await ensureDb();
const body = await request.json().catch(() => null);
if (!body) {
return NextResponse.json({ error: "Invalid request body" }, { status: 400 });