Im aiming at adding a feature to the mono-repo. 🤞
Locally, this works correctly but when deploying client/ to vercel w/ (Postgres db) and server/ types/ on aws nodejs w/ bitnami (different domain) i get cors error.
My goal is to ultimately deploy with evernode hotpocket after compiling the required "server" and directory files.
Some thoughts im having: our hosts allow access to user ports starting at :8080 + And peer ports at 22861 +
In the docs the server listens on :3001 and client on :3000
-
Can we modify this for client or server in config?
-
The db should reside on server or vercel?
-
Suggestions on compiling?
I greatly appreciate your feedback. ♟️
Hello. I haven't tried deploying this with different domains for the client and server, but it should probably work if you set the CORS_ORIGIN env variable on the server.
-
For the client, you can use the
-pflag to change the port (e.g.pnpm dev:client -p 8080orpnpm start:client -p 8080) - Next.js CLI. But I think Vercel handles this automatically when deploying?For the server, you can add the
PORTenvironment variable to change the server port.Here's the full list of environment variables you can use for the client and server (from CONTRIBUTING.md): client:
NEXT_PUBLIC_API_URL=http://localhost:3001 # replace with backend URLserver:
CORS_ORIGIN=http://localhost:3000 # replace with frontend URL PORT=3001 SESSION_SECRET=randomstring # replace for security # PostgreSQL connection info (required) PGHOST=db.example.com PGUSER=exampleuser PGPASSWORD=examplepassword PGDATABASE=chessu -
Ideally on the server, but it should work on Vercel Postgres or anywhere else as long as your Express/Node server can connect to it.
-
I used to deploy the client on Vercel, and the server/db on Railway.
For the client, I deployed the whole repo with these settings:
Make sure to set the Root Directory to
clientand check "Include source files outside ..." (edit: I'm not sure if the Install Command needs to be overridden. Try using their default option if it doesn't work.)For the server, I also deployed the whole repo (but only the root package.json,
server/, andtypes/folders are needed). Then on the root directory of the repo/project,pnpm install:serverto only install server dependencies,pnpm build:server, thenpnpm start:server.You can check the root
package.jsonfor the full list of scripts/commands to help you deploy each environment.
Hope that helps :)