How secure is to define database env variable with prefix `NEXT_PUBLIC_`?
See original GitHub issueExposing sensitive values to the browser is not a good idea.
I believe database value is only used on API routes. In that case, those are purely backend serverless functions. We donāt need to provide a NEXT_PUBLIC_
prefix if it is just used directly from the backend.
You can check more details here. https://nextjs.org/docs/basic-features/environment-variables
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Is sensitive data in NextJS .env file safe if it ... - Stack Overflow
Yes, NEXT_PUBLIC prefix allows NextJS to send the variable to the client's browser. From the docs: The value will be inlined into JavaScriptĀ ......
Read more >Basic Features: Environment Variables - Next.js
Learn to add and access environment variables in your Next.js application. ... Node.js environment automatically allowing you to use them in Next.js data...
Read more >How to setup custom environment variables other than ...
Hi, I would like to know how can I create a custom environment variable lets say staging and specify it during build time...
Read more >Environment variables in Next.js and Netlify
env.local you have to prefix the variable with NEXT_PUBLIC_ . // .env.local. SITE_URL=localhost
Read more >Environment Variables in Next.js - Frontend Digest
I didn't know how to set up variables for development and⦠... will load environment variables from a file called .env.local at the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Param-Harrison Thank you. Can you please create a PR for that?
NEXT_PUBLIC_DATABASE_URL
is used in the nextauth.ts file. Itās used only on API routes. Iāll check whether NextAuth will work if we donāt provide the credentials on the client side.