Railway envs

default discord avatar
Nball
8 months ago
5

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?

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.