2

i can't connect to the websocket because of my CSP (Content Security Policy) - what is wrong?

Error:

ps-client-component-websocket-adapter.js:412 Refused to connect to 'wss://hostname.domain:port/jsonWebSocket' because it violates the following Content Security Policy directive: "connect-src 'self'".

My IIS web.config

 <?xml version="1.0" encoding="UTF-8"?>
        <configuration>
            <system.webServer>
                <httpProtocol>
                    <customHeaders>
                        <add name="Cache-Control" value="no-cache" />   
                        <!---<add name="X-Content-Security-Policy" value="default-src 'self' 'unsafe-eval'; connect-src 'self'; img-src 'self'; object-src 'none'; child-src *;" />-->
                        <add name="Content-Security-Policy" value="connect-src 'self' wss://hostname.domain:port/jsonWebSocket; default-src 'self' 'unsafe-eval'; img-src * data:; object-src 'none'; child-src *;" />              
                    </customHeaders>
                </httpProtocol>
            </system.webServer>
        </configuration>
        </configuration>

2 Answers2

0

It seems like you are missing comma in connect-src.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Ely ILiyn
  • 11
  • 1
0

A bit late to the party, but as per MDN,

connect-src 'self' does not resolve to websocket schemas in all browsers, more info in this issue.

You may want to add wss to connect-src as it is done in this answer for example.

lnstadrum
  • 550
  • 3
  • 15