Repository navigation
fix(approuter): enable websockets so /event-display WS upgrade isn't 403'd - #1694
Merged
Merged
Conversation
…403'd
The event-display kiosk (hugo-apps/src/event-display) opens a Socket.IO
connection with transports:['websocket'] (no long-poll fallback) to
namespace /ws/event-stream via the default /socket.io/ engine.io path.
On deployed envs the WS upgrade returned "403 Forbidden" during the
handshake. Root cause: xs-app.json had no top-level `websockets` block.
Stock @sap/approuter v16.9.0 rejects every upgrade when it isn't enabled
(lib/websockets/WsProxy.js:84-85 -> authorizationRequired 'websockets are
disabled' -> 403), before the Origin check even runs. HTTP polling GETs to
the same /socket.io/ route pass through (200), which is why the initial
handshake + REST bucket fetch worked but the live stream never connected.
The custom upgrade proxy in approuter/server.js is isLocal-gated, so this
only affected deployed envs (DEV/QA/PROD), not local `cds watch`.
Fix: add `"websockets": { "enabled": true }` (validated against the
approuter's own xs-app schema). Bump MTA patch version for the deploy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
/event-display/?eventId=...&theme=jouleshows a WebSocket connection error. Browser console:Reproduced on the PROD approuter host directly (so not Akamai) — and identically on DEV.
Root cause
approuter/xs-app.jsonhad no top-levelwebsocketsblock. Stock@sap/approuterv16.9.0 rejects every WebSocket upgrade when websockets aren't enabled:This gate runs before the Origin check, so the upgrade never reaches the CAP backend. HTTP polling GETs to the same
/socket.io/route pass through (verified 200 + valid engine.iosid), which is why the initial handshake and the/rest/event-stream/getEventBucketsfetch worked but the live stream never connected.The event-display client (
hugo-apps/src/event-display/useEventStream.ts:83-88) opens Socket.IO withtransports: ['websocket'](no long-poll fallback), so the failed upgrade surfaces immediately asconnect_error.The custom upgrade proxy in
approuter/server.jsisisLocal-gated, so this only affected deployed envs (DEV/QA/PROD), never localcds watch— which masked it.The
@cap-js-community/websocketplugin docs call for exactly this ({ "websockets": { "enabled": true } }); it was simply never added here.Fix
"websockets": { "enabled": true }toapprouter/xs-app.json(validated against the approuter's ownxs-app-schema.json—enabled: booleanrequired).Verification
/socket.io/→ 200 (+sid); WS upgrade → 403Forbidden; browser console 403 during handshake.mbt build+ full deploy, no--skip-build/-mscoping): load/event-display/?eventId=10000004&theme=joule, confirm noconnect_error, and that a WS upgrade to/socket.io/?...&transport=websocketreturns 101, not 403.Follow-up to consider (out of scope here)
When served from the vanity domain developers.sap.com (behind Akamai), the browser
Originishttps://developers.sap.com. The approuter's post-enablement Origin check must see that as the app URL (via forwarded host) or it will 403 on origin instead. If that surfaces, setWS_ALLOWED_ORIGINSaccordingly. Not needed for the cfapps approuter host in this report.