From 7412bc8af5ae65539f1f492e57946ecc3a17c987 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 4 Jun 2026 17:46:42 +0100 Subject: [PATCH] Fix dev --- frontend/src/scripts/configuration.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/scripts/configuration.ts b/frontend/src/scripts/configuration.ts index 2fafd25..d3b16fe 100644 --- a/frontend/src/scripts/configuration.ts +++ b/frontend/src/scripts/configuration.ts @@ -6,7 +6,21 @@ * only shows a server once it responds, so listing an offline origin here is * harmless. Add or remove origins as you deploy more server containers. */ -const servers: Array = ['https://server.decla.red']; +const productionServers: Array = ['https://declared.schmelczer.dev']; + +/** + * When the page is served from localhost (i.e. the webpack-dev-server), also + * offer the local backend so a `npm start` server can be joined during + * development. The backend's default port is 3000 (see backend/src/options.ts). + * In production the hostname is `declared.schmelczer.dev`, so this never leaks. + */ +const isDevelopment = + typeof location !== 'undefined' && + (location.hostname === 'localhost' || location.hostname === '127.0.0.1'); + +const servers: Array = isDevelopment + ? [`http://${location.hostname}:3000`, ...productionServers] + : productionServers; export abstract class Configuration { public static async initialize(): Promise {