diff --git a/frontend/.env.example b/frontend/.env.example
index 22001c8..15242e3 100644
--- a/frontend/.env.example
+++ b/frontend/.env.example
@@ -5,3 +5,6 @@ VITE_BACKEND_URL=http://localhost:8080
# Frontend dev server port
# The Vite development server will run on this port
VITE_PORT=5173
+
+# Origin sent on the dev WebSocket proxy, for a backend with an allowed-origins list
+# VITE_WS_ORIGIN=https://gohoarder.example.com
diff --git a/frontend/index.html b/frontend/index.html
index 545285a..43feab1 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -4,6 +4,7 @@
+
GoHoarder dashboard
diff --git a/frontend/src/components/BypassManagementPanel.vue b/frontend/src/components/BypassManagementPanel.vue
index c93c0eb..2d32ff7 100644
--- a/frontend/src/components/BypassManagementPanel.vue
+++ b/frontend/src/components/BypassManagementPanel.vue
@@ -137,6 +137,24 @@
+
+
('')
+const keyInput = ref('')
+const showKeyDialog = ref(false)
const filteredBypasses = computed(() => {
let filtered = bypasses.value
@@ -264,16 +284,23 @@ onMounted(() => {
})
function promptForApiKey() {
- const key = prompt('Enter your admin API key:')
- if (key) {
- apiKey.value = key
- localStorage.setItem('admin_api_key', key)
- fetchBypasses()
- } else {
- error.value = 'Admin API key required to manage bypasses'
- }
+ keyInput.value = ''
+ showKeyDialog.value = true
}
+function submitApiKey() {
+ const key = keyInput.value.trim()
+ if (!key) return
+ apiKey.value = key
+ localStorage.setItem('admin_api_key', key)
+ showKeyDialog.value = false
+ fetchBypasses()
+}
+
+watch(showKeyDialog, (open) => {
+ if (!open && !apiKey.value) error.value = 'Admin API key required to manage bypasses'
+})
+
async function fetchBypasses() {
if (!apiKey.value) {
promptForApiKey()
diff --git a/frontend/src/components/views.smoke.spec.ts b/frontend/src/components/views.smoke.spec.ts
index ab2bbc7..2e4e763 100644
--- a/frontend/src/components/views.smoke.spec.ts
+++ b/frontend/src/components/views.smoke.spec.ts
@@ -140,6 +140,31 @@ describe('view smoke tests (strict mode throw, fixture data)', () => {
expect(document.body.querySelector('textarea')).not.toBeNull()
})
+ it('BypassManagementPanel asks for the admin key in a dialog, not a native prompt', async () => {
+ localStorage.clear()
+ const prompt = vi.spyOn(window, 'prompt')
+ const { wrapper, problems } = await smoke(BypassManagementPanel, '/admin/bypasses')
+ await flushPromises()
+ expect(problems).toEqual([])
+ expect(prompt).not.toHaveBeenCalled()
+ expect(document.body.textContent).toContain('Enter your admin API key to manage bypasses.')
+
+ const input = document.body.querySelector('input[type="password"]')
+ expect(input).not.toBeNull()
+ input!.value = 'secret-key'
+ input!.dispatchEvent(new Event('input', { bubbles: true }))
+ await flushPromises()
+ document.body.querySelector('input[type="password"]')!.form!.requestSubmit()
+ await flushPromises()
+
+ expect(localStorage.getItem('admin_api_key')).toBe('secret-key')
+ expect(vi.mocked(axios.get)).toHaveBeenCalledWith(
+ expect.stringContaining('/api/admin/bypasses'),
+ expect.objectContaining({ headers: { Authorization: 'Bearer secret-key' } }),
+ )
+ expect(wrapper.text()).toContain('CVE-2026-0002')
+ })
+
it('Stats renders totals, the storage tile and the registry table', async () => {
const { wrapper, problems } = await smoke(Stats, '/stats')
expect(problems).toEqual([])
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 5593d9a..7cb85b3 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -5,6 +5,7 @@ import { themeBootScript } from '@perfect-design/ui/stores/theme-boot'
// Get backend URL from environment or use default
const BACKEND_URL = process.env.VITE_BACKEND_URL || 'http://localhost:8080'
+const WS_ORIGIN = process.env.VITE_WS_ORIGIN
const FRONTEND_PORT = parseInt(process.env.VITE_PORT || '5173')
// Applies the saved colour mode before first paint so a dark system never flashes light.
@@ -33,6 +34,8 @@ export default defineConfig({
target: BACKEND_URL.replace('http', 'ws'),
ws: true,
changeOrigin: true,
+ // A backend with an origin allowlist refuses the dev server origin; set this to an allowed one.
+ ...(WS_ORIGIN ? { headers: { Origin: WS_ORIGIN } } : {}),
},
},
},