Using Config to Fallback to Another Environment Variable in TypeScript

Hello, how would I do this logic with Config

const value = yield* Config.string("ENV").pipe(Config.orElse("ENV2"))


I have tried every possible combination of config.orElse, config.option, config.andThen that I could think of.

This is my latest try, but the type is wrong.

  const appUrl = yield* Config.string("APP_URL").pipe(
    Config.option,
    Effect.andThen((option) =>
      Option.match(option, {
        onSome: (value) => value,
        onNone: () => Config.string("VERCEL_URL")
      }),
    ),
  );


What I want is if there is no APP_URL, I want to return VERCEL_URL, and let it throw ConfigError if there is no VERCEL_URL. Anyone?
Was this page helpful?