question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lighthouse broken when CSP connect-src 'none'

See original GitHub issue

Chrome v64 DEV Tools Audits hangs forever without returning result. Lighthouse v2.8.0 extension would throw error:

VM204:5 Refused to connect to ‘http://example.com/’ because it violates the following Content Security Policy directive: “default-src ‘none’”. Note that ‘connect-src’ was not explicitly set, so ‘default-src’ is used as a fallback.

__nativePromise.resolve.then._ @ VM204:5 Promise.then (async) (anonymous) @ VM204:5 wrapInNativePromise @ VM204:3 (anonymous) @ VM204:21 VM204:5 Refused to connect to ‘http://example.com/’ because it violates the document’s Content Security Policy.

Content-Security-Policy: default-src 'none'; connect-src 'self' would solve the issue, but I think Lighthouse mustn’t break and depend on connect-src ‘self’.

Once was open related issue https://github.com/GoogleChrome/lighthouse/issues/2319

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
lukiffercommented, Apr 23, 2020

It took a while to discover this issue and FWIW, a more descriptive error message would be helpful when the CSP blocks the request as opposed to an HTTP error response.

At a minimum, it would be helpful to add to the documentation for this check under “Common errors include:”

3reactions
lauksteincommented, Jul 23, 2018

The same error also in getRobotsTxtContent (Lighthouse v3.0.3) resulting “robots.txt is not valid”

Lighthouse was unable to download your robots.txt file

Refused to connect to 'https://example.com/robots.txt' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

getRobotsTxtContent @ VM1773:7
__nativePromise.resolve.then._ @ VM1773:17
Promise.then (async)
(anonymous) @ VM1773:5
wrapInNativePromise @ VM1773:3
(anonymous) @ VM1773:31

grabilla g10024

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSP: connect-src - HTTP - MDN Web Docs - Mozilla
The HTTP Content-Security-Policy (CSP) connect-src directive restricts the URLs which can be loaded using script interfaces.
Read more >
Mitigate cross-site scripting (XSS) with a strict Content Security ...
Learn how to deploy a CSP based on script nonces or hashes as a defense-in-depth against cross-site scripting.
Read more >
CSP added but Lighthouse flags it as missing
Ive added a CSP via PHP but Lighthouse is still saying. 'Ensure CSP is effective against XSS attacks'. Heres my CSP, is there...
Read more >
How to Implement Security HTTP Headers to Prevent ...
Prevent XSS, clickjacking, code injection attacks by implementing the Content Security Policy (CSP) header in your web page HTTP response.
Read more >
The Spyglass Portal: A Lighthouse Novel - Amazon.com
The Spyglass Portal: A Lighthouse Novel [Coverstone, Stacey] on Amazon.com. ... soul has been connected to hers for longer than either of them...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found