把http升級以后,一打開原本的網站,會發現很多靜態資源失效了。
只需要在html頁面加入:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
2:ajax請求與顯示跨域
當發送ajax請求時報錯:
XMLHttpRequest cannot load 【ajax請求的服務器url】 No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 【自己服務器】 is therefore not allowed access.
這個時候直接百度應該有很多種辦法可以解決
我選擇了在nginx中配置跨域支持功能;
還是在nginx.conf中加入代碼:
http { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; }
然后重啟nginx服務器即可
重啟nginx服務器命令:# /usr/local/nginx/sbin/nginx -s reload