Next.js Discord

Discord Forum

ENV variable isn't accessible in production

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Avatar
Cape lionOP
I am facing an issues my env base url isn't accessible in my server components that is dynamic , in localhost , it fetch the meta setting and update it properly but in production it show undefined

now if i use hardcoded url of API like i simple write it https://api.domain.com/api/get-meta-setting?selectedPage=home then it work fine but if i use

${baseURL}/api/get-meta-setting?selectedPage=home then it show undefined so probably the problem is becuase of env variable .

also it work fine in localhost using ENV , while in production it didn't work as expected , i have tried create build application locally and its work as expected

the problem is only existing in production , i hosted in on aws amplify , while my other ENV like decode secreat are working fine also the same base url it working for rtk query same code same thing

0 Replies