Fix serverless functions: simplify API structure

- Replace complex Express-style handler with simple module.exports
- Add separate API endpoints for better organization
- Simplify vercel.json routing configuration
- Remove ES modules to use CommonJS for Vercel compatibility
- Add dedicated test API endpoint for debugging
This commit is contained in:
2025-08-21 13:32:53 +09:00
parent ec5da4db32
commit 08894eeb66
5 changed files with 73 additions and 43 deletions

View File

@@ -1,59 +1,29 @@
{
"version": 2,
"builds": [
{
"src": "api/simple.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/api/(.*)",
"dest": "/api/simple.js"
"src": "/api/test",
"dest": "/api/test.js"
},
{
"src": "/health",
"dest": "/api/simple.js"
"src": "/api/files/public",
"dest": "/api/files.js"
},
{
"src": "/(.*\\.(css|js|json|svg|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot|html))",
"headers": {
"Cache-Control": "public, max-age=31536000, immutable"
},
"src": "/api/files",
"dest": "/api/files.js"
},
{
"src": "/(.*\\.(css|js|json|svg|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot))",
"dest": "/$1"
},
{
"src": "/index\\.html",
"headers": {
"Cache-Control": "public, max-age=0, must-revalidate"
},
"dest": "/index.html"
},
{
"src": "/admin/(.*)",
"dest": "/admin/$1"
},
{
"src": "^/$",
"dest": "/api/simple.js"
},
{
"src": "/(.*)",
"dest": "/index.html"
}
],
"headers": [
{
"source": "/api/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=0, s-maxage=86400"
}
]
}
],
"env": {
"NODE_ENV": "production"
}
]
}