2015-01-15 4 views
4

Google 글꼴 URL을 내 Content-Security-Policy 헤더의 font-src 지시문에 추가했습니다.Google 크롬에서 내용 보안 정책 오류가 발생했습니다

Refused to load the stylesheet 'http://fonts.googleapis.com/css? 
family=Open+Sans:300,400,400italic,600,800|Source+Code+Pro' because it violates the 
following Content Security Policy directive: "style-src 'self' 'unsafe-inline'". 

내 헤더 필드는 다음과 같습니다 : 나는 크롬 42에서 다음과 같은 오류를 받고 있어요

Content-Security-Policy: default-src 'self'; font-src http://fonts.googleapis.com; 
style-src 'self' 'unsafe-inline' 

답변

9

문제는 그 http://fonts.googleapis.com 반환 스타일이 아닌 글꼴에 대한 링크. 스타일 시트를 살펴보면 http://fonts.gstatic.com에서 글꼴을 가져 오는 @ font-face 규칙이 여러 개 발견됩니다. 당신이 경우

Content-Security-Policy: default-src 'self'; font-src https://fonts.gstatic.com; 
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com 
1

:

제대로, 콘텐츠 보안과 정책 헤더처럼 보일 것이다이 작품을 만들려면 나처럼 조금 혼란 스럽다. 모든 대답은 style-src 지시문에서 URL을 승인해야한다고 말하는 것이기 때문에 혼란 스럽다. 여기에 풀 태그가있다 :

<meta http-equiv="Content-Security-Policy" content="style-src 'self' 'unsafe-inline' http://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com;"> 
0

: 나는 https 변화가 나에 대한 요구 사항이었다 실행 발견

Content-Security-Policy: default-src 'self'; font-src http://fonts.gstatic.com; 
style-src 'self' 'unsafe-inline' http://fonts.googleapis.com