简体   繁体   English

Angular 4-模板URL从https更改为http?

[英]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.

相关问题 AngularJS:通过https提供$资源,从https到http的Angular交换机 - AngularJS: Serving $resource via https, Angular switches from https to http Angular 2 中的动态模板 URL - Dynamic template URLs in Angular 2 链接到相对路径 HTML 文件,但从 HTTP 更改为 HTTPS - Linking to relative path HTML file but changing from HTTP to HTTPS 将协议从 http 更改为 https 时出现 Google Analytics 错误 - Google Analytics error when changing protocol from http to https 没有 http、https、ftp 的网址的正则表达式 - Regex for urls without http, https, ftp 以http://或https://开头的网址,以逗号分隔,不能有空格 - URLs starting with http:// or https://, separated by comma, no spaces 从部署在Z80791B3AE7002CB88C8Z服务器的Angular调用HTTPS API - Calling HTTPS API from Angular deployed in http server Angular 7 - ngOnInit - window.location.href 不工作 - 从 HTTPS 到 HTTP - Angular 7 - ngOnInit - window.location.href not working - From HTTPS to HTTP http to https-使浏览器为http URL请求相应的https URL,而无需编辑所有页面并将所有URL手动更改为https? - http to https - Make browser request corresponding https URLs for http URLs, without needing to edit all pages and manually change all URLs to https? Angular 组件未更改模板 - Angular component not changing template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM