diff --git a/.env.example b/.env.example index f9affad..de4d90c 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ # Backend - server-side only (NEVER commit .env) SECRET_KEY=change_me_in_production SQLITE_PATH=./data/homelab.db +# Set this to the URL(s) you use to access Homelable in your browser. CORS_ORIGINS=["http://localhost:5173","http://localhost:3000"] # Auth — default credentials: admin / admin diff --git a/docker-compose.yml b/docker-compose.yml index 613d572..16c9b2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,8 @@ services: env_file: - .env environment: - # Override env_file values that differ in Docker + # Override env_file: SQLite path must point inside the container volume SQLITE_PATH: /app/data/homelab.db - CORS_ORIGINS: '["http://localhost:3000"]' volumes: - backend_data:/app/data networks: diff --git a/frontend/src/components/LoginPage.tsx b/frontend/src/components/LoginPage.tsx index 7fbbb0e..3272798 100644 --- a/frontend/src/components/LoginPage.tsx +++ b/frontend/src/components/LoginPage.tsx @@ -20,8 +20,9 @@ export function LoginPage() { try { const res = await authApi.login(username, password) login(res.data.access_token) - } catch { - setError('Invalid username or password') + } catch (err: unknown) { + const hasResponse = err && typeof err === 'object' && 'response' in err + setError(hasResponse ? 'Invalid username or password' : 'Could not reach the server — check your CORS_ORIGINS setting') } finally { setLoading(false) } @@ -95,7 +96,7 @@ export function LoginPage() {
- Credentials configured in config.yml + Credentials configured in .env
diff --git a/frontend/src/components/__tests__/LoginPage.test.tsx b/frontend/src/components/__tests__/LoginPage.test.tsx index 9b617a6..416ea74 100644 --- a/frontend/src/components/__tests__/LoginPage.test.tsx +++ b/frontend/src/components/__tests__/LoginPage.test.tsx @@ -51,7 +51,7 @@ describe('LoginPage', () => { }) it('shows a generic error message — no credential enumeration', async () => { - vi.mocked(authApi.login).mockRejectedValue(new Error('401')) + vi.mocked(authApi.login).mockRejectedValue({ response: { status: 401 } }) render(