-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Currently, Wasp provides both the config and env objects.
env provides raw environment variables values, with types for well-known Wasp provided env vars (e.g. WASP_WEB_CLIENT_URL) and user-defined validated env vars.
config provides the same well-known Wasp provided env vars (not user-defined validated env vars) but under different names, e.g.
WASP_WEB_CLIENT_URL -> frontendUrl
The biggest problem here is that even though they refer to the same "env vars" they hold different values.
This is because we normalize the values inside of the config object.
e.g. how we define URLs for config
// waspc/data/Generator/templates/sdk/wasp/server/config.ts
const frontendUrl = stripTrailingSlash(env["{= clientUrlEnvVarName =}"])
const serverUrl = stripTrailingSlash(env["{= serverUrlEnvVarName =}"])The reason why we do it is because WASP_WEB_CLIENT_URL generates with trailing forward slash (presumably because of strong-path), while for example WASP_SERVER_URL doesn't have it:

Should we even provide two different objects with "the same purpose"?
I think we definitely should remove the repetition + normalize all values.
We have three different inputs to our env var objects which we can treat differently:
- well-known Wasp env vars (e.g.
frontendUrl/WASP_WEB_CLIENT_URL) - user defined validated env vars
- user defined non-validated env vars