Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Railway envs

default discord avatar
nball2 years ago
2

Whist testing the Next Preview example (

https://github.com/payloadcms/payload/tree/master/examples/preview

) everything works great locally, but when attempting to build locally or deploy to Railway/Vercel, yarn errors out code 1.



The example config includes this line


cors: [process.env.PAYLOAD_PUBLIC_SERVER_URL, process.env.PAYLOAD_PUBLIC_SITE_URL],



And console tells me the strings are loading from ENV normally within both config and server, eg.


http://adminzone.up.railway.app
http://payload-nextjs.vercel.app

I feel like I am missing something obvious here…



The plot thickens, process.env.PAYLOAD_PUBLIC_SERVER_URL and process.env.PAYLOAD_PUBLIC_SITE_URL are undefined on build.



It seems the build command does not append the .env like dev does. PAYLOAD_PUBLIC_SITE_URL, PAYLOAD_PUBLIC_SERVER_URL, MONGODB_URI, PAYLOAD_SECRET, REVALIDATION_KEY, COOKIE_DOMAIN are all missing. I have added these when deploying to Railway, but get the same error regardless. Any ideas?

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.