nginx配置之后,出现css、js无法加载成功

从http切换到https出现js、css无法加载的原因其实很简单,就是协议的问题。

location ~ \.css {
       add_header  Content-Type    text/css;
}
location ~ \.js {
       add_header  Content-Type    application/x-javascript;
}

只需要在nginx上面加上头部支持混合协议就搞定了这个问题了。

这是一些原理的文章,给大家参考一下:

https://imququ.com/post/sth-about-switch-to-https.html

https://stackoverrun.com/cn/q/2653771

https://developers.google.com/web/fundamentals/security/prevent-mixed-content/fixing-mixed-content?hl=zh-cn

未经允许不得转载:微信信息发源地 » nginx配置之后,出现css、js无法加载成功

赞 (2)
分享到:更多 ()

评论 0

评论前必须登录!

登陆 注册