mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
Merge pull request #530 from Tria-plc/freight/feat/chat-app
fix: websocket fix attempt
This commit is contained in:
@@ -35,8 +35,12 @@ function buildCsp(nonce: string): string {
|
||||
? `'self' 'nonce-${nonce}' 'strict-dynamic'`
|
||||
: `'self' 'unsafe-inline' 'unsafe-eval'`;
|
||||
|
||||
// The Socket.IO WebSocket upgrade connects to wss://<api-host>; under CSP a
|
||||
// `https://host` source does NOT cover `wss://host`, so add it explicitly.
|
||||
const wsOrigin = apiOrigin.replace(/^http/, 'ws'); // https→wss, http→ws
|
||||
|
||||
const connectSrc = isProd
|
||||
? `'self' ${apiOrigin}`.trim()
|
||||
? `'self' ${apiOrigin} ${wsOrigin}`.trim()
|
||||
: `'self' ${apiOrigin} ws: wss:`.trim();
|
||||
|
||||
const directives = [
|
||||
|
||||
@@ -48,8 +48,12 @@ function buildCsp(nonce: string): string {
|
||||
? `'self' 'nonce-${nonce}' 'strict-dynamic'`
|
||||
: `'self' 'unsafe-inline' 'unsafe-eval'`;
|
||||
|
||||
// The Socket.IO WebSocket upgrade connects to wss://<api-host>; under CSP a
|
||||
// `https://host` source does NOT cover `wss://host`, so add it explicitly.
|
||||
const wsOrigin = apiOrigin.replace(/^http/, 'ws'); // https→wss, http→ws
|
||||
|
||||
const connectSrc = isProd
|
||||
? `'self' ${apiOrigin}`.trim()
|
||||
? `'self' ${apiOrigin} ${wsOrigin}`.trim()
|
||||
: `'self' ${apiOrigin} ws: wss:`.trim();
|
||||
|
||||
const directives = [
|
||||
|
||||
Reference in New Issue
Block a user