i tried to convert my simple express proxy server to serverless vercel code. i made the static file serving work. for somereason i can not get any endpoint to work. everything gives 404. build logs and details shows i have the functions at the right place api/test but i cant access them on the browser (url.com/api/test or url.com/test). i tried fixing it for like 3 hours. completely started from scratch once. now i want some human ideas.
my project structure
api
-test.ts
public
-index.html
vercel.json
test.ts
import { VercelRequest, VercelResponse } from '@vercel/node';
export default function handler(req: VercelRequest, res: VercelResponse) {
res.status(200).json({ message: 'Hello' });
}
vercel.json
{
"build": {
"env": {
"NODE_ENV": "production"
}
},
"installCommand": "corepack enable && corepack prepare pnpm@10.0.0 --activate && pnpm install",
"builds": [
{
"src": "public/**",
"use": "@vercel/static"
},
{
"src": "api/**/*.ts",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/",
"dest": "/public/index.html"
},
{
"src": "/api/(.*)",
"dest": "/api/$1"
}
]
}
im assuming tsconfig.json can't cause any issues right? i did some fiddling with it but idk
do i have to specify each endpoint in the routes with that format? i thought it would be automatic. (tbh both didnt work)
I've tried in both local and production environments (both in hosted version and local vercel-cli version)