Next.js requiring env variables in build variables

I'm deploying a new Next.js app to a worker using OpenNext. However I'm running into an issue where it cannot detect env variables unless I also add them to the build variables in the dashboard. Is that normal?
3 Replies
JdX
JdX4mo ago
Yes its normal. U should always add env variables that contain NEXT_PUBLIC to your build variables.
jins
jinsOP4mo ago
It was looking for my DATABASE_URL and some other secrets. I don't have them exposed in client side components/pages though.
JdX
JdX4mo ago
Yup I currently have my DATABASE_URL and the NEXT_PUBLIC_R2_BUCKET in the build variables but u can encrypt it via the dashboard so I hope im safe

Did you find this page helpful?