Empire CMS has a correct Content-Type of text/javascript for ViewClick. However, if you add add_header X-Content-Type-Options "nosniff" always; in the Nginx configuration file, the frontend webpage will fail to display real-time click counts via: <script src=[!--news.url--]e/public/ViewClick/?classid=[!--classid--]&id=[!--id--]&addclick=1></script>
After investigation, it was found that Empire CMS's ViewClick does not actually return a text/javascript Content-Type. Previously, browsers relied on MIME sniffing to automatically correct this, but with nosniff enabled, sniffing is disabled and the script is directly rejected.
In different versions or configurations of Empire CMS, the ViewClick.php file either explicitly outputs header("Content-Type: text/javascript"), or relies on PHP's default value (text/html; charset=UTF-8).
Fix Solution:
Add the missing PHP Content-Type header.
Locate the ViewClick entry file (either /e/public/ViewClick/index.php or /e/public/ViewClick.php), and add the following line at the very beginning of the file (before any output):
header("Content-Type: text/javascript; charset=utf-8");Then, the original code that outputs the count remains like:
echo "document.write('" . $count . "');";Now the Content-Type is correctly set, and nosniff will no longer block it. At the same time, the security benefit of nosniff (preventing other resources from being misinterpreted as executable scripts by the browser) is preserved.
文章不错支持一下,非常喜欢
之前也遇到过这问题,配置文件配上后就不显示了