Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring
TypeScript diagramhomelabhomelab-infrastructure-observabilitynetworkproxmox-veself-hostedzigbeezwavezwave-js
fix: remove hardcoded CORS_ORIGINS from docker-compose, improve login errors
Pouzor4aca82fb1a7b
diff --git a/.env.example b/.env.exampleindex 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_productionSQLITE_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 / admindiff --git a/docker-compose.yml b/docker-compose.ymlindex 613d572..16c9b2a 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -7,9 +7,8 @@ services:env_file:- .envenvironment:- # Override env_file values that differ in Docker+ # Override env_file: SQLite path must point inside the container volumeSQLITE_PATH: /app/data/homelab.db- CORS_ORIGINS: '["http://localhost:3000"]'volumes:- backend_data:/app/datanetworks:diff --git a/frontend/src/components/LoginPage.tsx b/frontend/src/components/LoginPage.tsxindex 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() {</form><p className="text-center text-[10px] text-muted-foreground/40 mt-4">- Credentials configured in <span className="font-mono">config.yml</span>+ Credentials configured in <span className="font-mono">.env</span></p></div></div>diff --git a/frontend/src/components/__tests__/LoginPage.test.tsx b/frontend/src/components/__tests__/LoginPage.test.tsxindex 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(<LoginPage />)fireEvent.change(screen.getByLabelText('Username'), { target: { value: 'admin' } })fireEvent.change(screen.getByLabelText('Password'), { target: { value: 'wrongpass' } })@@ -65,6 +65,17 @@ describe('LoginPage', () => {expect(errors[0].textContent).toBe('Invalid username or password')})+ it('shows a network error message when no response (e.g. CORS misconfiguration)', async () => {+ vi.mocked(authApi.login).mockRejectedValue(new Error('Network Error'))+ render(<LoginPage />)+ fireEvent.change(screen.getByLabelText('Username'), { target: { value: 'admin' } })+ fireEvent.change(screen.getByLabelText('Password'), { target: { value: 'admin' } })+ fireEvent.submit(screen.getByRole('button', { name: /sign in/i }).closest('form')!)+ await waitFor(() => {+ expect(screen.getByText(/Could not reach the server/)).toBeDefined()+ })+ })+it('clears previous error before each new attempt', async () => {vi.mocked(authApi.login).mockRejectedValueOnce(new Error('401'))