Next.js Discord

Discord Forum

intrumentation.ts env loading

Unanswered
LaPerm posted this in #help-forum
Open in Discord
LaPermOP
i wanted to load my env vars from 3rd party api fetch using the new instrumentation.ts file and it works awesome on server side but on client side they are not set even when they start with NEXT_PUBLIC_ any ideas how to solve that?

i saw also instrumentation-client.ts but is it secure to call an api with api token retrieving the env vars in here, wont it be exposed to the site users?

1 Reply

LaPermOP
okay so tested a bit and when i use fetch in instrumentation-client.ts this request is made on client side, hence api key is exposed to a user. So how could i load client side env variables from external api? I assume they are needed at build time already?