大网数据广告活动
服务器运维问答

Refused to connect to 'http://someURL' because it violates the following Content Security Policy directive: "connect-src http://someURL"

· 52CE 我爱测

Well, that's the error which comes up from my browser console, I am working with one domain and that domain has only one sub-domain, and I still don't have access to the sub-domain. Actually I am receiving some other errors. My g…

问题原文

原帖链接 · Reacting · CC BY-SA 3.0

Well, that's the error which comes up from my browser console, I am working with one domain and that domain has only one sub-domain, and I still don't have access to the sub-domain. Actually I am receiving some other errors.

My guess is that the mistake I have is in the add_header Content-Security-Policy, in the connect-src part. : this is the domain part and the Content-Security-Policy:

server {
    large_client_header_buffers 1 1K;

    listen       80;
    server_name  www.just4bettors.mobi  just4bettors.mobi;
    root   /home/c0pt/capilleira/capilleiraclickandgamblemobile/www;

    location / {
        index  index.html index.htm;
        ...
    }

    add_header Content-Security-Policy
    "default-src 'self' http://just4bettors.mobi:1337;
     connect-src http://just4bettors.mobi
                 http://just4bettors.mobi:1337
                 http://www.just4bettors.mobi
                 http://www.just4bettors.mobi:1337";
}

and this is the part for the sub-domain:

server {
   listen 80;
   server_name www.desktop.just4bettors.mobi  desktop.just4bettors.mobi;
   root   /home/c0pt/capilleira/capilleiraclickandgambleweb/dist;
   location / {
        index index.html index.htm;
        ...
   }

   add_header Content-Security-Policy add_header
   "default-src 'self' http://www.just4bettors.mobi;
    connect-src http://just4bettors.mobi
                http://just4bettors.mobi:1337
                http://www.just4bettors.mobi
                http://www.just4bettors.mobi:1337
                http://www.desktop.just4bettors.mobi:1337
                http://www.desktop.just4bettors.mobi";
}

this part of the errors I am getting in the console

Refused to connect to 'http://www.desktop.just4bettors.mobi/views/accFiguresModal.html' because it violates the following Content Security Policy directive: "connect-src http://just4bettors.mobi http://just4bettors.mobi:1337 http://www.just4bettors.mobi http://www.just4bettors.mobi:1337".

the issue actually comes up only when I try to connect to www.desktop.just4bettors.mobi but if I put www.just4bettors.mobi everything works properly

so, where is my error here ?

已采纳解答

原帖链接 · Non · CC BY-SA 4.0

Try add header Content-Security-Policy to your meta tag:

"connect-src http://just4bettors.mobi http://just4bettors.mobi:1337 http://www.just4bettors.mobi http://www.desktop.just4bettors.mobi;"

Complete meta tag will be like this:

"default-src 'self' http://www.just4bettors.mobi; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' http://placehold.it https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.gstatic.com  https://themes.googleusercontent.com https://assets.zendesk.com; font-src 'self' https://themes.googleusercontent.com https://fonts.gstatic.com; frame-src 'self'; object-src 'none'; connect-src http://just4bettors.mobi http://just4bettors.mobi:1337 http://www.just4bettors.mobi http://www.desktop.just4bettors.mobi;"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。