Development Tip

Google 경고 : 리소스가 글꼴로 해석되지만 MIME 유형 application / octet-stream으로 전송 됨

yourdevel 2020. 11. 6. 20:41
반응형

Google 경고 : 리소스가 글꼴로 해석되지만 MIME 유형 application / octet-stream으로 전송 됨


내 글꼴에 대한 Google 경고가 있습니다.

리소스는 글꼴로 해석되지만 MIME 유형 application / octet-stream : "... / Content / Fonts / iconFont.ttf"로 전송됩니다.

이 경고가 있어도 작동하지만이 경고를 피하는 것이 좋습니다.

내 선언은 다음과 같습니다.

@font-face {
  font-family: 'iconFont';
     src: url('../Fonts/iconFont.eot?#iefix') format('embedded-opentype'), 
     url('../Fonts/iconFont.svg#iconFont') format('image/svg+xml'), 
     url('../Fonts/iconFont.woff') format('font/x-woff'), 
     url('../Fonts/iconFont.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

이미 다른 게시물을 검색했지만 지금까지는 운이 없습니다.

내 서버는 Microsoft의 IIS입니다.

이 경고를 어떻게 피할 수 있습니까?

감사.


여기에 또 다른 접근 방식 : http://zduck.com/2013/google-chrome-and-woff-font-mime-type-warnings/

web.config에서 아래 설정을 사용하십시오.

<system.webServer>
<staticContent>
  <mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
</staticContent>
</system.webServer>

.htaccess / IIS에 다음 유형을 추가해야합니다.

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/font-woff .woff  

.woff 유형을 다음에서 업데이트했습니다.

AddType application/x-font-woff .woff

(이 점을 지적 해 주신 아래 댓글의 @renadeen에게 감사드립니다.)

비슷한 질문에 대한 내 대답을 여기에서 확인하십시오. 글꼴이로드되지 않았습니다.

여기에서 가져온 것 : 크롬의 글꼴 문제 .


위의 답변 @ 97ldave에 감사드립니다. 이러한 유형을 IIS 설정에서 MIME 유형에 직접 추가하지 않으려면 IIS 웹 서버 구성 섹션에 추가 할 수 있습니다. 다음은 구성에서 누락 된 .woff 유형 만 추가하는 예를 보여줍니다. iMac에서 최신 버전의 Safari (6.0.3)에 표시되지 않는 글꼴 문제가 해결되었습니다.

<system.webServer>
<staticContent>
  <remove fileExtension=".woff" />
  <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
</system.webServer>

이것을 발견 한 Jon Samwell (제 동료)에게 감사드립니다.


Nginx의 경우 : (경로 : /etc/nginx/mime.types)

font/ttf                         ttf;
font/otf                         otf;
application/x-font-woff          woff;

application/vnd.ms-fontobject eot;이미 존재하므로 필요하지 않습니다.

Nginx를 다시 시작한 후 : service nginx restart

끝난.


글꼴에 대한 올바른 MIME 유형은 다음과 같습니다.

application/font-ttf              ttf;
application/font-otf              otf;
application/font-woff             woff;

nodeJS로 서버를 실행하는 경우 MIME 유형을 매핑하는 좋은 모듈입니다.

https://github.com/broofa/node-mime

var mime = require('mime');

mime.lookup('/path/to/file.txt');         // => 'text/plain'
mime.lookup('file.txt');                  // => 'text/plain'
mime.lookup('.TXT');                      // => 'text/plain'
mime.lookup('htm');                       // => 'text/html'

mime.extension('text/html');                 // => 'html'
mime.extension('application/octet-stream');  // => 'bin'

Thanks to @the-senator and @97ldave for their answers

for me the error completely disappear just after adding these lines to the web.config

<system.webServer>
<staticContent>
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/x-font" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="application/x-font" />
    </staticContent>
</system.webServer>

참고URL : https://stackoverflow.com/questions/15521130/google-warning-resource-interpreted-as-font-but-transferred-with-mime-type-appl

반응형