从运行在http中的网站使用https访问CDN [英] Accessing CDN using https from a website running in http

查看:58
本文介绍了从运行在http中的网站使用https访问CDN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个将在http中创建的网站.我试图包括来自google cdn的jquery.

I am developing a website which is going to be in http. I was trying to include jquery from google cdn.

此处给出的答案

使用协议相对URL,可以轻松避免混合的内容安全错误.

来自 google cdn ,它被视为

我们建议您通过HTTPS从CDN加载库,即使您自己的网站仅使用HTTP.

We recommend that you load libraries from the CDN via HTTPS, even if your own website only uses HTTP.

我认为这两个是矛盾的.基本上,当我们在http中拥有一个网站并通过https使用cdn时,人们可能会想到与内容相关的错误吗?现在推荐使用Whay吗?

I see these two as contradictory. Basically, when we have a website in http and using cdn through https, what are the content related errors one can expect? Whay is the recommended approach now?

推荐答案

在没有HTTPS的环境中进行本地开发是相当普遍的.使用协议相对URL意味着您可以在HTTP上进行开发,而不必担心每次部署到生产环境时都要记住将其切换到HTTPS.

It's fairly common to do local development in an environment without HTTPS. Using the protocol-relative URL means you can develop on HTTP and not have to worry about remembering to switch it to HTTPS every time you deploy to production.

不过,对于CDN,无论您是在本地还是在生产环境中,都可以确信CDN具有HTTPS,因此在此处对HTTPS URL进行硬编码是完全可以的.

For CDNs, though, you can be assured the CDN has HTTPS whether you're working locally or in production, so it's entirely fine to hard-code the HTTPS URL there.

这篇关于从运行在http中的网站使用https访问CDN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆