You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current documentation suggests prefixing API keys with NEXT_PUBLIC for environment variables in Next.js applications. However, this could potentially lead to security vulnerabilities as these keys may inadvertently be exposed to the client side.
Solution
The official Next.js documentation source recommends not using the NEXT_PUBLIC prefix for sensitive environment variables, such as API keys. By removing the prefix, these variables remain private and can only be accessed on the server, minimizing the risk of unintentional client-side exposure.
Reference
Next.js documentation advises against using the NEXT_PUBLIC prefix for sensitive environment variables:
"Since the environment variable API_KEY is not prefixed with NEXT_PUBLIC, it's a private variable that can only be accessed on the server. To prevent your environment variables from being leaked to the client, Next.js replaces private environment variables with an empty string."
The text was updated successfully, but these errors were encountered:
Yaren-IT
changed the title
Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in Documentation Issue Description
Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in Documentation
Nov 22, 2023
Yaren-IT
changed the title
Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in Documentation
Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in .env File
Nov 22, 2023
@Yaren-IT I think this would be a good change. When I initially build this I did not mind keeping NEXT_PUBLIC and it made the variable accessible client side. But this would be a good refactor to do. I would add it to my todo, but if you would like to make a PR before than. Feel free to do so.
Just have to check, that where ever we are using none NEXT_PUBLIC env we will have to refactor some logic to run the code server side. Because I believe we wont be able to access those variables client side.
PaulBratslavsky
changed the title
Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in .env File
TODO: Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in .env File
Dec 3, 2023
Problem
The current documentation suggests prefixing API keys with NEXT_PUBLIC for environment variables in Next.js applications. However, this could potentially lead to security vulnerabilities as these keys may inadvertently be exposed to the client side.
Solution
The official Next.js documentation source recommends not using the NEXT_PUBLIC prefix for sensitive environment variables, such as API keys. By removing the prefix, these variables remain private and can only be accessed on the server, minimizing the risk of unintentional client-side exposure.
Reference
Next.js documentation advises against using the NEXT_PUBLIC prefix for sensitive environment variables:
The text was updated successfully, but these errors were encountered: