Skip to content

Bridge the gap between config and env objects #3332

@FranjoMindek

Description

@FranjoMindek

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:
Image

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:

  1. well-known Wasp env vars (e.g. frontendUrl/WASP_WEB_CLIENT_URL)
  2. user defined validated env vars
  3. user defined non-validated env vars

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxhmmRequires more thought

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions