Summary
Hello, I’m trying to deploy a server of a particular package in monorepo using vercel. When I test it with vercel dev
in my local environment, my api work fine. But after I deploy the production, when I go to the deployed link, I always see only the api/index.js
source code. And Runtime Log doesn’t show anything. Any tips for solving it?
Example
Deploy Link : https://all-about-dog-server.vercel.app/
Steps to Reproduce
I have configured the server code as below:
vercel.json
- I checked the Using Express.js with Verceldocument and configured vercel.json as below.
{ "version": 2, "rewrites": [{ "source": "/(.*)", "destination": "/api" }] }
package.json
- I understand that Vercel’s deployment path should be under the
/api
directory. So I wrote avercel-build
script to bundle the source code of theapp
directory and store it in theapi
directory.
=> Could there be a problem with this method?
{
"name": "@all-about-som/server",
"version": "1.0.0",
"description": "All about dog server",
"main": "index.js",
"scripts": {
"start": "nodemon --exec ts-node -r tsconfig-paths/register app/index.ts",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsup app --clean --format cjs,esm --env.NODE_ENV production",
"vercel-build": "tsup app --clean --format cjs --env.NODE_ENV production --env.DEPLOYMENT_ENV vercel --out-dir api"
},
mongo db Setting
- I confirmed that the link between MongoDB Atlas and Vercel is also working well.
- IP Address set to 0.0.0.0/0
- MongoDB Atlas is linked to Vercel’s Integrations
MONGODB_URI
is set in Vercel’s Environment Variables (id, pw match)
- Vercel Build & Development Settings
- Output Directory :
.
Fortunately, since it is a private project, I share the entire code as below:
Github : younyikim-playground/apps/all-about-som/server at main · younyikim/younyikim-playground · GitHub
Since there is no explanation in English on how to execute the project, I leave a separate guide here.
- You can go to Project Root, clone the repository, install dependency through
pnpm i
and run it. - The project can be accessed directly from Root using the
pnpm all-about-some:server
command.- ex)
pnpm all-about-som:server start
,pnpm all-about-som:server vercel dev
- Alternatively, you can access it by going directly to
cd apps/all-about-some/server
.
- ex)
Any ideas?