refactor(integrations): read the OAuth redirect URIs through the env helpers

The seven integration clients now read their redirect URI and the app URL
through envValue/envOr instead of a local ?.trim() ||. The empty-env guard
drops its pending entry and floors its walk, and proves its matcher still
fires on a real client with the old read put back.
This commit is contained in:
Marc-André Bombeck committed 2026-09-26 17:08:47 +02:00
1 parent 903f0a9a22
commit cc60b82d84
8 files changed
+45 -38

No files matched your search

+3 -2
View File
@@ -42,6 +42,7 @@ import { safeFetch } from "@/lib/safe-fetch";
import { canonicalDailyTimestamp } from "@/lib/measurements/consolidation-tz";
import { zonedWallClockToUtc } from "@/lib/tz/wall-clock";
import { FitbitApiError, classifyFitbitResponse } from "./response-classifier";
import { envValue } from "@/lib/env";
/** Classic Fitbit Web API base. */
export const FITBIT_API_BASE = "https://api.fitbit.com";
@@ -80,8 +81,8 @@ export function getFitbitRedirectUri(): string {
// An empty or blank value counts as unset: the compose whitelist
// materialises an unset var as an empty string, which must fall through to
// the derived URI rather than read as "not configured".
const explicit = process.env.FITBIT_REDIRECT_URI?.trim() || undefined;
const appUrl = process.env.NEXT_PUBLIC_APP_URL?.trim() || undefined;
const explicit = envValue("FITBIT_REDIRECT_URI");
const appUrl = envValue("NEXT_PUBLIC_APP_URL");
const raw =
explicit ?? (appUrl ? `${appUrl}/api/fitbit/callback` : undefined);