0

If the user has no activity(mouse, keyboard) in some period of time, API'S not working, I inspected and went to the network tab and found CSP is blocking.

Tried by adding meta link, but it's not working.

Attempt:

<meta http-equiv="Content-Security-Policy"
        content="default-src 'self';script-src 'unsafe-hashes' 'unsafe-inline' 'my-urls' ;">

Tried by adding meta link, but it's not working.

XD Sauaame
  • 45
  • 8

1 Answers1

0
  1. Since you observe CSP blocking, you already have a CSP published in the page. You can't relax this CSP by publishing a second CSP in meta tag, you need to edit a first one.
    You can check what CSP your already have in browser, a tutorial is here.

  2. XHR requests are covered by connect-src directive, therefore you have to add connect-src 'self' or connect-src https://your_domain.com if you perform connect to a site's own domain.
    But first check a "Console tab" - it should be a CSP violation message like:

    Refused to connect to wss://example.com/ because it violates the following Content Security Policy directive ...

    Refused to connect to https://example.com/ because it violates the following Content Security Policy directive ...

You need to verify that wss://example.com/ or https://example.com/ is your legitimate domain, because this can be antics of some browser plugin or third-party iframe on page.
After thar you can add wss://example.com/ or https://example.com/ (depending what is blocked) into connect-src directive.

granty
  • 7,234
  • 1
  • 14
  • 21