In localhost I have my environment variable
PAYLOAD_PUBLIC_SERVER_URL="http://localhost:3000"
, that is read from
serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL
The question is, when deploying in production in Cloud Run for example, should this environment variable be assigned, and if so, what url should I assign to this environment variable?
Yep - very important that you assign this variable. It needs to be the domain you wanna access payload from. So if you set up a custom domain, it would need to be that
Once your service starts for the first time (even though it’s not working without that variable), you’ll see the assigned url in the service info on cloud run. Copy that and just add the url into the environment variables of the service.
All good info! I'm also noticing that your environment variable is using quotation marks, these should be removed so that it reads
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000
instead.
Star
Discord
online
Get dedicated engineering support directly from the Payload team..