Firebase托管上的网站可以包含非https资源吗?

问题描述:

我一直在尝试将网站从divshot迁移到firebase,因为firebase接管了divshot并将其关闭.

I have been trying to migrate my site from divshot to firebase, since firebase has taken over divshot and shut it down.

Mine是一个不需要https的简单只读网站.它还包含指向不支持https的外部站点的链接.该网站在divshot上运行良好,但似乎Firebase强制所有网站使用https.不幸的是,这导致我的站点引用的外部站点无法加载.错误是:

Mine is a simple read only site that does not need https. It also contains links to external sites which do not support https. The site worked perfectly on divshot but it looks like firebase forces all sites to use https. Unfortunately, this causes the external sites that my site references to fail loading. The error being:

混合内容:" https://mysite.firebaseapp.com/上的页面已加载HTTPS,但请求了不安全的资源" http://www.externalsite.com/".该请求已被阻止;内容必须通过HTTPS提供.

Mixed Content: The page at 'https://mysite.firebaseapp.com/' was loaded over HTTPS, but requested an insecure resource 'http://www.externalsite.com/'. This request has been blocked; the content must be served over HTTPS.

我试图删除http :,所以外部站点只是//www.externalsite.com/,但这会导致证书错误.由于该外部网站不支持,因此无法将其更改为https.

I tried to remove the http: so the external site is just //www.externalsite.com/, but this causes certificate errors. I can't change it to https since this external site doesn't support it.

有没有办法解决这个问题?

Is there any way around this problem?

简短的回答是否".这完全是设计使然.允许在https站点上使用http是安全漏洞.因此它被阻止了.

The short answer is no. This is completely by design. It's a security flaw to allow http on a https site. Therefore it's blocked.

但是,

  • 解决方案1:查找https版本的资源.在您的情况下,这可能无法实现.
  • 解决方案2:将资源转换为https 可能可以通过https自己托管文件或资源.这可能需要您复制文件或其他内容(我会仔细说),不要盗版您不应该使用的东西.
  • 解决方案3:重定向:这可能是最复杂的解决方案,但是如果您尝试访问某些服务,则可以制作自己的服务来重定向它.您正在使用Firebase,这意味着您可能可以一起破解一些云功能以发出http请求(
  • Solution 1: Find a https version of resource This might not be possible in your case.
  • Solution 2: convert resource to https It might be possible to host the file or resource yourself with https. This may require you to copy a file or something, which I say carefully, don't pirate stuff that you shouldn't.
  • Solution 3: Redirect This one is probably the most involved solution to do but if you are trying to access some service then you could make your own service to redirect it. You are on firebase which means you could probably hack together some cloud function to make a http request (How to make an HTTP request in Cloud Functions for Firebase?)
  • Solution 4: Don't use Firebase Don't want to do any of the above and you can't live with out the http call? You might just dump firebase and move to some other hosting service.

希望这对您有所帮助,但这可能不是您要找的答案,但可能会为您指明正确的方向.

Hope you find this helpful it might not be the answer your looking for but it might point you in the right direction.