From 7d75e74679bcad95dbff9f27d822197d563a0f38 Mon Sep 17 00:00:00 2001 From: elpatron Date: Sat, 30 May 2026 13:59:15 +0200 Subject: [PATCH] fix: CORS-Origins, Sync-Body-Limit und geteilte Logbuch-Rolle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Erlaubt mehrere/normalisierte CORS-Origins mit Dev-Fallbacks für Session-Cookies, stellt express.json wieder auf 50mb für große Sync-Payloads und setzt die Zugriffsrolle beim Wechsel in geteilte Logbücher ohne Cache korrekt. Co-authored-by: Cursor --- .env.example | 4 +++- client/src/App.tsx | 14 +++++++---- server/src/cors.ts | 58 +++++++++++++++++++++++++++++++++++++++++++++ server/src/index.ts | 13 ++++------ 4 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 server/src/cors.ts diff --git a/.env.example b/.env.example index 2d3f8fd..26b84d3 100755 --- a/.env.example +++ b/.env.example @@ -4,8 +4,10 @@ OpenWeatherMapAPIKey= # For local dev: localhost and http://localhost # For production: e.g. kapteins-daagbok.eu and https://kapteins-daagbok.eu RP_ID=localhost -# Must match the frontend URL (Vite dev: http://localhost:5173) +# Must match the frontend URL (Vite dev: http://localhost:5173; Docker: http://localhost) ORIGIN=http://localhost:5173 +# Optional: comma-separated CORS origins (defaults to ORIGIN; dev also allows 127.0.0.1:5173) +# CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173 # API session signing (min. 32 chars; required in production) # Generate: openssl rand -base64 48 diff --git a/client/src/App.tsx b/client/src/App.tsx index 18b444c..5beea97 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -40,19 +40,20 @@ import { getStoredDemoFirstEntryId, seedDemoLogbookIfNeeded } from './services/demoLogbook.js' -import { fetchLogbooks } from './services/logbook.js' +import { fetchLogbooks, parseCollaborationRole } from './services/logbook.js' import { ensurePushSubscriptionIfEnabled } from './services/pushNotifications.js' const PENDING_PUSH_LOGBOOK_KEY = 'pending_push_logbook_id' function App() { const { t, i18n } = useTranslation() - const { registerNavigation, requestStartAfterLogin } = useAppTour() + const { registerNavigation, requestStartAfterLogin, isActive, currentStepId } = useAppTour() const [isAuthenticated, setIsAuthenticated] = useState(false) const [activeLogbookId, setActiveLogbookId] = useState(null) const [activeLogbookTitle, setActiveLogbookTitle] = useState(null) const [activeTab, setActiveTab] = useState('logs') const [tourSelectedEntryId, setTourSelectedEntryId] = useState(null) + const [tourFeedbackOpen, setTourFeedbackOpen] = useState(false) const [demoHighlightEntryId, setDemoHighlightEntryId] = useState(null) const [online, setOnline] = useState(navigator.onLine) const [isSyncing, setIsSyncing] = useState(false) @@ -90,9 +91,11 @@ function App() { } const cachedRole = activeLogbookRecord.collaborationRole - if (cachedRole) { - setActiveAccessRole(cachedRole) - } + setActiveAccessRole( + cachedRole + ? parseCollaborationRole(cachedRole, `logbook ${activeLogbookId}`) + : 'WRITE' + ) getLogbookAccess(activeLogbookId).then((access) => { if (access) setActiveAccessRole(access.role) @@ -503,6 +506,7 @@ function App() {