Ionic2 CSP拒绝加载base64映像
我正在处理一个ionic 2应用程序,从控制台收到错误消息,指出拒绝加载映像和脚本,因为它违反了CSP规则 至于图像,它是以blob的形式存储在数据库中的。我能够获取base64值,但无法在应用程序上显示它 Index.htmlIonic2 CSP拒绝加载base64映像,ionic2,content-security-policy,Ionic2,Content Security Policy,我正在处理一个ionic 2应用程序,从控制台收到错误消息,指出拒绝加载映像和脚本,因为它违反了CSP规则 至于图像,它是以blob的形式存储在数据库中的。我能够获取base64值,但无法在应用程序上显示它 Index.html <head> <meta http-equiv="Content-Security-Policy" content=" img-src 'self' data: https://s-media-cache-ak0.pinimg.c
<head>
<meta http-equiv="Content-Security-Policy" content="
img-src 'self' data: https://s-media-cache-ak0.pinimg.com;
" />
</head>
<ion-card>
<img src="data:image/png;base64,{{storePhoto}}">
</ion-card>
组件ts
import { DomSanitizer } from '@angular/platform-browser';
constructor(public DomSanitizerService : DomSanitizer){}
<img [src]="_DomSanitizationService.bypassSecurityTrustUrl(data:image/png;base64,{{storePhoto}})" />
Uncaught(承诺中):错误:模板解析错误:解析器错误:获取插值({{})
消息表明需要添加https://s-media-cache-ak0.pinimg.com
您的保单:
您是否真的像这样添加了CSP标记或组件html?因为它需要在您的index.html
文件中,请使用编辑/更新您的问题,并添加您在浏览器开发工具中看到的确切错误消息console@Andreas加斯曼:是的。我将它添加到mainindex.html
中,而不是组件html中。很抱歉。