[英]Angular 4 - Template URLs Changing from https to http?
I have a template in my Angular 4 app that pulls images from an https:// URL, and works fine when the app is hosted locally via 'ng serve': 我的Angular 4应用程序中有一个模板,可从https:// URL中提取图像,并且当该应用程序通过'ng serve'本地托管时工作正常:
<div class="poster_div" *ngIf="movie_details['poster_path']">
<img src="https://image.tmdb.org/t/p/w185{{movie_details['poster_path']}}" />
</div>
However-- now that I've deployed the site ( and am serving it with Apache HTTP), these images are being pulled from http instead (causing the dreaded 'mixed content' error in the browser). 但是,既然我已经部署了该站点(并通过Apache HTTP为其提供服务),那么这些图像就从http提取了(导致浏览器中出现可怕的“混合内容”错误)。 Is there a setting in 'ng build' that causes this?
在“ ng build”中是否存在导致此设置的设置? Or is is some wacky side effect with Apache?
还是Apache的古怪副作用?
'Inspect Element' from local: 从本地“检查元素”:
<img _ngcontent-c1="" src="https://image.tmdb.org/t/p/w185/ApYhuwBWzl29Oxe9JJsgL7qILbD.jpg">
'Inspect Element' from remote site: 从远程站点“检查元素”:
<img _ngcontent-c1="" src="http://image.tmdb.org/t/p/w185/ApYhuwBWzl29Oxe9JJsgL7qILbD.jpg">
Remove the protocol from your image URL, so you have a relative URL. 从图片网址中删除协议,因此有了相对网址。 This will then use the correct protocol that the visitor is using when visiting the site.
然后,它将使用访问者在访问站点时使用的正确协议。
<div class="poster_div" *ngIf="movie_details['poster_path']">
<img src="//image.tmdb.org/t/p/w185{{movie_details['poster_path']}}" />
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.