EDIT: I encountered this issue when I was loading my project as a chrome extension. I think this might be a chrome extension specific issue.
When I try to search on the google customized search engine I get a result page but it is blank. When I inspect it I get the following error:
Refused to load the script 'http://clients1.google.com/complete/search?client=partner&hl=en&sugexp=gsno…208%3Avdsj6wr1edq&types=t&ds=cse&cp=1&gs_id=4&q=m&callback=google.sbox.p50' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' https://*.google.com".
I think this is because the script is using 'http'. Base on Google's Content Security Policy 'http' origins are not accepted
As man-in-the-middle attacks are both trivial and undetectable over HTTP, those origins will not be accepted. - https://developer.chrome.com/extensions/contentSecurityPolicy#relaxing
my html:
<html>
<head>
<script src="fact.js"></script>
</head>
<body>
<div id="gcse-search-bar">
<gcse:search defaultToImageSearch="true"></gcse:search>
</div>
</body>
</html>
my js file. In my case it is call fact.js
document.addEventListener('DOMContentLoaded', function() {
(function() {
var cx = '016674471602576918208:vdsj6wr1edq';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
});
My manifest.json:
{
"manifest_version": 2,
"name": "my extension",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://*.google.com; object-src 'self'",
"description": "my extension",
"version": "1.0",
"browser_action": {
"default_icon": "my.png",
"default_popup": "my.html"
},
"permissions": [
"activeTab",
"http://*/*",
"https://*/*",
"https://En.wikipedia.org/*",
"http://*.google.com/"
],
"content_scripts": [{
"js": ["fact.js"],
"matches": ["http://*/*", "https://*/*"]
}]
}
What do I need to do to have return results use HTTPS instead of HTTP?