diff --git a/.env.sample b/.env.sample index 3bd68d8e4..51d02bf37 100644 --- a/.env.sample +++ b/.env.sample @@ -18,6 +18,7 @@ FCC_ENABLE_DEV_LOGIN_MODE=true # Student progress data. The mock server (pnpm run mock-fcc-data) is the default. # Set FCC_API_URL and TPA_API_BEARER_TOKEN to use the freeCodeCamp API instead. +# Production requires FCC_API_URL. MOCK_USER_DATA_URL=http://localhost:3002/data FCC_API_URL= TPA_API_BEARER_TOKEN= diff --git a/__tests__/utils/env.test.ts b/__tests__/utils/env.test.ts index 189738c20..cd228b877 100644 --- a/__tests__/utils/env.test.ts +++ b/__tests__/utils/env.test.ts @@ -15,7 +15,9 @@ const productionEnv: NodeJS.ProcessEnv = { NEXTAUTH_SECRET: 'test-production-secret', AUTH0_DOMAIN: 'example.auth0.com', AUTH0_CLIENT_ID: 'test-client-id', - AUTH0_CLIENT_SECRET: 'test-client-secret' + AUTH0_CLIENT_SECRET: 'test-client-secret', + // TODO: replace with the real freeCodeCamp API URL once it is confirmed + FCC_API_URL: 'https://api.example.org' }; describe('findEnvProblems', () => { @@ -64,6 +66,11 @@ describe('findEnvProblems', () => { ]); }); + it('requires FCC_API_URL in production', () => { + const env: NodeJS.ProcessEnv = { ...productionEnv, FCC_API_URL: undefined }; + expect(findEnvProblems(env)).toEqual(['FCC_API_URL is not set']); + }); + it('rejects dev login mode in production', () => { const env: NodeJS.ProcessEnv = { ...productionEnv, diff --git a/util/env.ts b/util/env.ts index c7c9cf411..0961b311f 100644 --- a/util/env.ts +++ b/util/env.ts @@ -9,7 +9,8 @@ const ALWAYS_REQUIRED: string[] = [ const PRODUCTION_REQUIRED: string[] = [ 'AUTH0_DOMAIN', 'AUTH0_CLIENT_ID', - 'AUTH0_CLIENT_SECRET' + 'AUTH0_CLIENT_SECRET', + 'FCC_API_URL' ]; export function findEnvProblems(env: NodeJS.ProcessEnv): string[] {