diff --git a/.github/workflows/test_next_server.yml b/.github/workflows/test_next_server.yml index d7201e03..892566d6 100644 --- a/.github/workflows/test_next_server.yml +++ b/.github/workflows/test_next_server.yml @@ -42,11 +42,4 @@ jobs: run: pnpm install - name: Run tests - run: pnpm test - env: - NEXT_PUBLIC_IS_CI: true - - - name: Build - run: pnpm build - env: - NEXT_PUBLIC_IS_CI: true \ No newline at end of file + run: pnpm test \ No newline at end of file diff --git a/www/app/lib/apiClient.tsx b/www/app/lib/apiClient.tsx index d8d95deb..8ba11c6a 100644 --- a/www/app/lib/apiClient.tsx +++ b/www/app/lib/apiClient.tsx @@ -10,11 +10,8 @@ import { } from "@tanstack/react-query"; import createFetchClient from "openapi-react-query"; import { assertExistsAndNonEmptyString } from "./utils"; -import { isCI } from "./next"; -const API_URL = !isCI - ? assertExistsAndNonEmptyString(process.env.NEXT_PUBLIC_API_URL) - : "http://127.0.0.1:1250"; +const API_URL = assertExistsAndNonEmptyString(process.env.NEXT_PUBLIC_API_URL); // Create the base openapi-fetch client with a default URL // The actual URL will be set via middleware in AuthProvider diff --git a/www/app/lib/authBackend.ts b/www/app/lib/authBackend.ts index 45548054..f091cd6d 100644 --- a/www/app/lib/authBackend.ts +++ b/www/app/lib/authBackend.ts @@ -17,16 +17,15 @@ import { deleteTokenCache, } from "./redisTokenCache"; import { tokenCacheRedis } from "./redisClient"; -import { isCI } from "./next"; // REFRESH_ACCESS_TOKEN_BEFORE because refresh is based on access token expiration (imagine we cache it 30 days) const TOKEN_CACHE_TTL = REFRESH_ACCESS_TOKEN_BEFORE; const refreshLocks = new Map>(); -const CLIENT_ID = !isCI - ? assertExistsAndNonEmptyString(process.env.AUTHENTIK_CLIENT_ID) - : "noop"; +const CLIENT_ID = assertExistsAndNonEmptyString( + process.env.AUTHENTIK_CLIENT_ID, +); const CLIENT_SECRET = !isCI ? assertExistsAndNonEmptyString(process.env.AUTHENTIK_CLIENT_SECRET) : "noop"; diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index cd0e5a47..2c06dd06 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -1,7 +1,5 @@ import { get } from "@vercel/edge-config"; -import { isBuildPhase, isCI } from "./next"; - type EdgeConfig = { [domainWithDash: string]: { features: { @@ -30,12 +28,6 @@ export function edgeDomainToKey(domain: string) { // get edge config server-side (prefer DomainContext when available), domain is the hostname export async function getConfig() { - if (isCI) { - // "noop" - // TODO sometime later we may have proper config if we have bigger test suite that requires values from the config - return require("../../config-template").localConfig; - } - if (process.env.NEXT_PUBLIC_ENV === "development") { // helps to stop nextjs build from eager loading. don't inline it. const configPath = "../../config"; diff --git a/www/app/lib/next.ts b/www/app/lib/next.ts index bdc58eb4..91d88bd2 100644 --- a/www/app/lib/next.ts +++ b/www/app/lib/next.ts @@ -1,7 +1,2 @@ // next.js tries to run all the lib code during build phase; we don't always want it when e.g. we have connections initialized we don't want to have export const isBuildPhase = process.env.NEXT_PHASE?.includes("build"); -// useful for "next build" conditional executions -export const isCI = - process.env.CI === "true" || - process.env.IS_CI === "true" || - process.env.NEXT_PUBLIC_IS_CI === "true"; diff --git a/www/app/lib/redisClient.ts b/www/app/lib/redisClient.ts index 1be36538..c85c0e9e 100644 --- a/www/app/lib/redisClient.ts +++ b/www/app/lib/redisClient.ts @@ -1,5 +1,4 @@ import Redis from "ioredis"; -import { isBuildPhase } from "./next"; export type RedisClient = Pick; @@ -27,20 +26,4 @@ const getRedisClient = (): RedisClient => { return redis; }; -// next.js buildtime usage - we want to isolate next.js "build" time concepts here -const noopClient: RedisClient = (() => { - const noopSetex: Redis["setex"] = async () => { - return "OK" as const; - }; - const noopDel: Redis["del"] = async () => { - return 0; - }; - return { - get: async () => { - return null; - }, - setex: noopSetex, - del: noopDel, - }; -})(); -export const tokenCacheRedis = isBuildPhase ? noopClient : getRedisClient(); +export const tokenCacheRedis = getRedisClient();