Hi!
##Current versus Expected behavior
Current behavior:
* Deployment fails with TypeError: Missing parameter name at 6: [https://git.new/pathToRegexpError](https://git.new/pathToRegexpError)* Serverless function crashes immediately on any request* Error occurs regardless of rewrite configuration or handler filename* Project is completely unusable despite valid setupExpected behavior:
* SPA routes (like /login, /admin) should work without 404 errors* API routes should be accessible via /api/** Express serverless function should serve the React frontend build* Deployment should succeed with proper rewrites##Code, configuration, and steps that reproduce this issue
Project structure: root/ ├── api/ │ └── main.js # Express serverless function ├── backend/ │ ├── routes/ # API routes │ ├── services/ # Database services │ └── dist/ # Frontend build output ├── components/ # React components ├── vercel.json # Rewrites configuration └── package.json
vercel.json: { "rewrites": [ { "source": "/api/(.)", "destination": "/api/$1" }, { "source": "/(.)", "destination": "/api/main" } ] }
api/main.js: const express = require('express'); const serverless = require('serverless-http'); const path = require('path');
const app = express();// Middleware setupapp.use(helmet());app.use(cors());app.use(express.json());// API routesapp.use('/api/auth', require('./backend/routes/auth'));app.use('/api/blog', require('./backend/routes/blog'));// ... other routes// Serve static frontend buildapp.use(express.static(path.join(__dirname, 'backend/dist')));// SPA fallbackapp.get('*', (req, res) => { res.sendFile(path.join(__dirname, 'backend/dist/index.html'));});module.exports = { default: serverless(app) };Steps to reproduce: 1. Deploy project to Vercel 2. Access any SPA route (e.g., /login) 3. Check deployment logs 4. See path-to-regexp error
Troubleshooting steps already tried:
* ✅ Deleted and recreated Vercel project completely* ✅ Changed handler filename from index.js to main.js* ✅ Tested all rewrite patterns from documentation* ✅ Verified no duplicate files in /api directory* ✅ Confirmed all dependencies in package.json* ✅ Checked environment variables* ✅ Used both CommonJS and ESM module systems* ✅ Simplified rewrites to basic patterns##Project information (framework, environment, project settings) - Framework: React (Vite) + Express - Build Command: npm run build && npm run copy-dist - Output Directory: dist - Install Command: npm install - Root Directory: ./
Environment Variables: * SUPABASE_URL * SUPABASE_ANON_KEY * JWT_SECRET * NODE_ENV=production
package.json scripts: { "scripts": { "build": "vite build", "copy-dist": "cp -r backend/dist .", "vercel-build": "npm run build && npm run copy-dist" } }
Dependencies: * Frontend: React, Vite, Tailwind CSS * Backend: Express, serverless-http, cors, helmet, bcryptjs, /supabase-js
Error logs: 2025-07-18T16:09:51.094Z [error] TypeError: Missing parameter name at 6: https://git.new/pathToRegexpError at name (/var/task/node_modules/path-to-regexp/dist/index.js:73:19) at lexer (/var/task/node_modules/path-to-regexp/dist/index.js:91:27) at lexer.next () at Iter.peek (/var/task/node_modules/path-to-regexp/dist/index.js:106:38) at Iter.tryConsume (/var/task/node_modules/path-to-regexp/dist/index.js:112:28) at Iter.text (/var/task/node_modules/path-to-regexp/dist/index.js:128:30) at consume (/var/task/node_modules/path-to-regexp/dist/index.js:152:29) at parse (/var/task/node_modules/path-to-regexp/dist/index.js:183:20) at /var/task/node_modules/path-to-regexp/dist/index.js:294:74 at Array.map () Node.js process exited with exit status: 1
Question: Is this a known Vercel platform issue? How can I get my project working again? The error suggests a problem with Vercel's internal path-to-regexp compilation, not my code.
Thanks for any help!