This was a problem I couldn't find an easy answer to so I figured I would just post it here.
Attempting to use
results in an error at runtime.
- Prefix the environment variable in your .env with
- Use the
method of including the dotenv package:
import dotenv from 'dotenv'
- Invoke dotenv like so
- Access your environment variable like so:
When I do this, there is no build errorand
there is no js/network error at runtime.
Hope this helps someone in the future!
@jmikrut, we had chatted about this briefly in another prost. Just a heads up in case you're curious where this landed.
I found the answer here and implemented it how I described it above:https://github.com/payloadcms/payload/issues/1654#issuecomment-1419012718