te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Chrome console error: The Content Security Policy was delivered in report-only mode, but does not specify a &#3
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome console error: The Content Security Policy was delivered in report-only mode, but does not specify a &#3

programmeradmin3浏览0评论

In Chrome 73.0.3683.103 console, as of today, I am seeing the following error:

The Content Security Policy 'script-src 'report-sample' 'nonce-PNYOS1z63mBa/Tqkqyii' 'unsafe-inline';object-src 'none';base-uri 'self'' was delivered in report-only mode, but does not specify a 'report-uri'; the policy will have no effect. Please either add a 'report-uri' directive, or deliver the policy via the 'Content-Security-Policy' header.

I believe this is from script src=".js"... Everything seems to work. The initiator seems to be .html?usegapi=1...

What is causing this and how can I fix it?

Edit: As of today, I am no longer seeing the error. So I assume google has fixed this issue.

In Chrome 73.0.3683.103 console, as of today, I am seeing the following error:

The Content Security Policy 'script-src 'report-sample' 'nonce-PNYOS1z63mBa/Tqkqyii' 'unsafe-inline';object-src 'none';base-uri 'self'' was delivered in report-only mode, but does not specify a 'report-uri'; the policy will have no effect. Please either add a 'report-uri' directive, or deliver the policy via the 'Content-Security-Policy' header.

I believe this is from script src="https://apis.google./js/platform.js"... Everything seems to work. The initiator seems to be https://content.googleapis./static/proxy.html?usegapi=1...

What is causing this and how can I fix it?

Edit: As of today, I am no longer seeing the error. So I assume google has fixed this issue.

Share Improve this question edited Apr 17, 2019 at 0:10 Ted Scheckler asked Apr 5, 2019 at 13:47 Ted SchecklerTed Scheckler 1,5114 gold badges19 silver badges41 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9 +25

If the parent page is owned by you there's a couple of things you can do to correct this. If the parent page is not owned by you, there's nothing you can do, but this warning won't affect your experience.

First some background:

What is CSP?

A Content Security Policy or CSP is a header your server can set which tells the browser to enforce a whitelist of what content can run on your page, where it can e from, and how it can run. For example, you can limit what domains JavaScript is allowed to be fetched from, whether JavaScript can run inline, or where JavaScript can make xhr calls out to.

CSP can run in two modes: blocking and reporting.

In blocking mode the browser enforces the policy laid out in the CSP and applies those restrictions to your webpage. In blocking mode you can optionally have any blocked content be reported back to an endpoint you specify in the report-uri directive of the CSP. In reporting mode nothing is blocked only things that would get blocked get reported to the endpoint specified in the policies report-uri directive.

Your specific issue

The browser warning says that you're running in reporting mode but you haven't specified a report-uri so it doesn't know where to report violations. In effect, your CSP is doing nothing other than wasting bandwidth because it's not reporting or blocking any issues it's finding.

That leaves you with a few options:

  1. Do nothing. Your CSP won't alert you about any issues (outside of messages in the console) and it won't block any content.
  2. Add a report-uri (something like report-uri: https://example./csp_reports) to receive requests. Even if you're not receiving anything at that endpoint your specific console warning will disappear (you'll still get console errors for specific CSP violations even if they aren't blocked).
  3. Switch the CSP into blocking mode. You won't receive any reports but the warning will disappear as the CSP now serves a purpose of blocking content. Caution don't do this if it's saying it's blocking a lot of things. That's indicative that your site might break. First, fix the issues it's blocking by adjusting the CSP or changing what resources you're using and then flip it into blocking mode.
    1. Switch the CSP into blocking mode and add a report-uri. Long term, this is best solution from a security standpoint but the warning from step 3 applies.

If it was me, I would first add a report-uri to understand what warnings my page is generating (note some might be triggered by browser extensions - nothing you can do about that, but that's okay). Once I understand the mon warnings I'd tweak the CSP and what resources I have to make sure the page is loading without any warnings or errors in the console. Then I'd switch the CSP into blocking mode to take advantage of the security benefits it provides.

This is related to the server/backend level settings.

If you have access to your server from where code is served, you can set the header settings. So currently Content-Security-Policy-Report-Only this has been set without all required parameters. You can just check there and either remove this header (if not required), or set the required parameters.

You can find the header details from here

One possible solution is to remove some of the Chrome extensions. I had a similar issue in the past, and I was able to resolve it by disabling certain extensions that might have been conflicting with the Content Security Policy. By doing so, it allowed the web page to load without triggering the error. I remend trying this approach and see if it helps in resolving the issue.

Please note that this solution may not work in all cases, as the cause of the Content Security Policy error can vary. However, removing conflicting extensions is a good first step in troubleshooting and addressing such issues.

Remember to always review the extensions you remove and consider the impact they might have on your browsing experience or the functionality they provide.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论