//ads:
?>
"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page
PHP Snippet 1:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
PHP Snippet 2:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
PHP Snippet 3:
server {
...
add_header Strict-Transport-Security "max-age=31536000" always;
add_header Content-Security-Policy upgrade-insecure-requests;
...
}
PHP Snippet 4:
location ^~ /admin {
alias /home/user/apps/app_admin/dist;
index index.html;
try_files $uri $uri/ /index.html;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
}
PHP Snippet 5:
var f = document.createElement('form');
f.action='http://XX.XXX.XX.XX/vicidial/non_agent_api.php';
f.method='POST';
//f.target='_blank';
//f.enctype="multipart/form-data"
var k=document.createElement('input');
k.type='hidden';k.name='CustomerID';
k.value='7299';
f.appendChild(k);
//var z=document.getElementById("FileNameId")
//z.setAttribute("name", "IDProof");
//z.setAttribute("id", "IDProof");
//f.appendChild(z);
document.body.appendChild(f);
f.submit()
PHP Snippet 6:
if (window.location.protocol.indexOf('https') == 0){
var el = document.createElement('meta')
el.setAttribute('http-equiv', 'Content-Security-Policy')
el.setAttribute('content', 'upgrade-insecure-requests')
document.head.append(el)
}
PHP Snippet 7:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">