secrets from env file defined in Next config defined leaking in client.

I am using Nextjs 13.4.3, I have defined variables in next config coming from env file like:
const nextConfig = {
env: {
//Google MAPS API KEY
PLACES_API_KEY: process.env.PLACES_API_KEY,
},
const nextConfig = {
env: {
//Google MAPS API KEY
PLACES_API_KEY: process.env.PLACES_API_KEY,
},
the issue is it is getting leaked in the client, what can be solution?
1 Reply
Matvey
Matvey5mo ago
You don't need to add your env variables in next config this adds them to the client bundle just have the .env file and prefix your client variables with NEXT_PUBLIC env in next config is mostly for backwards comparability
Want results from more Discord servers?
Add your server