[Bug?] .env.local variables can not be accessed pages/api/<file>
Answered
American black bear posted this in #help-forum
American black bearOP
According to docs, .env.local variables should be accesible within api directory to make requests to hide secrets. If i try to access the varibales with proccess.env.<NAME> I get undefined values.
in pages/api/file.ts
Any help appriciated since I need to use API routes to hide API secrets.
in pages/api/file.ts
console.log(process.env.TWITCH_ID, ' ', process.env.TWITCH_SECRET); => Undefined UndefinedAny help appriciated since I need to use API routes to hide API secrets.
Answered by American black bear
seems to be bugged. If I use .env it works on the server side. Docs statel clearly that .env.local should be used AND that .env* should also work °_°
5 Replies
American black bearOP
seems to be bugged. If I use .env it works on the server side. Docs statel clearly that .env.local should be used AND that .env* should also work °_°
Answer
sth with your file paths I guess
if you're using the app directory, the path should be
if you're using the app directory, the path should be
app/api/posts/route.tsAmerican black bearOP
nah, it's just bugged
switched from .env.local to .env and it works
@American black bear seems to be bugged. If I use .env it works on the server side. Docs statel clearly that .env.local should be used AND that .env* should also work °_°
hmm maybe submit a bug report with a minimal reproduction repository