my file structure
sh
api
├── src
│ └── index.ts
├── .env
├── package.json
├── tsconfig.json
└── vercel.json
client
├── src
│ ├── App.tsx
│ └── main.tsx
├── .env
├── package.json
└── tsconfig.jsondelpoy node express back-end to vercel
- upload your code to github
- go to vercel dashboard
Framework PresetchooseotherRoot Directorychooseapi- add environment variables
- ENV_DATA
- PORT
- Deploy
add vercel.json to your node app (this is vital)
- vercel host support
.jsand.tsfiles, so we could just use it - also use full file name, use
src/index.tsinstead ofsrc
json
{
"version": 2,
"builds": [{ "src": "src/index.ts", "use": "@vercel/node" }],
"rewrites": [{ "source": "/(.*)", "destination": "src/index.ts" }]
}delpoy vite react front-end to vercel
- upload your code to github
- go to vercel dashboard
Framework PresetchooseviteRoot Directorychooseclient- add environment variables
- VITE_API_URL
- Deploy