Yes, this will include the API key in your frontend code. You should instead create an API endpoint or use Server Actions (if you're using nextjs) for this.
I'm a Full stack ninja crafting innovative solutions for real-world impact. Passionate about user-centric applications and driving business through technology.
That doesn't help. The variables will be exposed, since the build process will include them in the generated bundle. Dotenv only prevents it to be exposed to the git repository.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Would this approach expose your api key?
Yes, this will include the API key in your frontend code. You should instead create an API endpoint or use Server Actions (if you're using nextjs) for this.
Hello @greg, we should always use API key as environment variables in .env files.
That doesn't help. The variables will be exposed, since the build process will include them in the generated bundle. Dotenv only prevents it to be exposed to the git repository.