-
Create an
api/restful.js
file with the following content:require("../dist/src/main");
Or create an
api/restul.ts
file with:require("../src/main");
-
Create a
vercel.json
file with the following content:{ "framework": null, "outputDirectory": ".", "buildCommand": "npm run build", "functions": { "api/*.js": { "memory": 1024, "maxDuration": 10 } }, "rewrites": [ { "source": "/api(.*)", "destination": "/api/restful" }, { "source": "/(.*)", "destination": "/public" } ] }
-
Deploy by executing
vercel deploy
orvercel deploy --prod
. -
Locally development:
- You can just execute
vercel dev -l 3100
, which automatically loads the.env
file. You may need to runnpx nest build --watch
together. ExecuteI founddotenv npx nest start --watch
which manually loads the.env
file.--watch
doesn’t work in this way.- Execute
npx nest start --watch
which needs to add the following content in your codes to load the.env
file:export const isNestDev = !process.env.JWT_SECRET; if (isNestDev) { require("dotenv").config(); }
- You can just execute
How to deploy nestjs app to vercel
Published at at 07:04 PM at 07:27 PM