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
However, if there happens to be a typo in the specified environment variable name, envsafe is unable to identify the error. For instance, consider the following scenario where the PABLIC segment is incorrect (while PUBLIC is the correct one):
The reason behind this behavior is that envsafe relies on a fallback mechanism where it references the environment variable using NEXT_PUBLIC_NO_DEFAULT when the input value is empty.
Unfortunately, this fallback mechanism is ineffective for Next.js client-side applications. It causes delays in issue detection and creates unnecessary obstacles in such scenarios.
Proposal
I propose introducing an option that allows users to disable the fallback mechanism at their discretion. By adding, for instance, the inputOnly option, we give users the ability to control this behavior.
exportconstbrowserEnv=envsafe({NEXT_PUBLIC_NO_DEFAULT: str({input: process.env.NEXT_PUBLIC_NO_DEFAULT,// Only individual items can be targeted// inputOnly: true}),},{// By setting this flag to `true`, only the input value will be referenced, and the value in process.env will be ignored.inputOnly: true})
Utilizing this feature empowers Next.js application builders to detect typographical errors in environment variables during the build process, treating them as build errors rather than runtime issues.
I believe that the majority of cases where input is used are with Next.js.
Therefore, I thought it would be a good idea to make it the default behavior to disable fallback when using input.
However, I am not certain that anyone would find it harmful, so I opted to add the flag so as not to break the existing behavior.
The text was updated successfully, but these errors were encountered:
snaka
linked a pull request
Jun 3, 2023
that will
close
this issue
Problem
I'd like to highlight an issue that arises when passing environment variables to
envsafe
in Next.js, using the code from the Example as a reference.In Next.js applications, we use the
input
option to inline environment variable values during the build process and pass them toenvsafe
.However, if there happens to be a typo in the specified environment variable name, envsafe is unable to identify the error. For instance, consider the following scenario where the
PABLIC
segment is incorrect (whilePUBLIC
is the correct one):The reason behind this behavior is that
envsafe
relies on a fallback mechanism where it references the environment variable usingNEXT_PUBLIC_NO_DEFAULT
when theinput
value is empty.Unfortunately, this fallback mechanism is ineffective for Next.js client-side applications. It causes delays in issue detection and creates unnecessary obstacles in such scenarios.
Proposal
I propose introducing an option that allows users to disable the fallback mechanism at their discretion. By adding, for instance, the
inputOnly
option, we give users the ability to control this behavior.Utilizing this feature empowers Next.js application builders to detect typographical errors in environment variables during the build process, treating them as build errors rather than runtime issues.
Pull Request
inputOnly
option for exclusive input utilization #144I believe that the majority of cases where
input
is used are with Next.js.Therefore, I thought it would be a good idea to make it the default behavior to disable fallback when using
input
.However, I am not certain that anyone would find it harmful, so I opted to add the flag so as not to break the existing behavior.
The text was updated successfully, but these errors were encountered: