GitHub CDN 사용하기

GitHub CDN 사용하기
Refused to execute script from http://raw.githubusercontent.com

1 문제상황[ | ]

  • raw.githubusercontent.com 로 접근하면 거부됨
<link rel="stylesheet" href="//raw.githubusercontent.com/xdan/datetimepicker/master/jquery.datetimepicker.css">
<script src="//raw.githubusercontent.com/xdan/datetimepicker/master/jquery.datetimepicker.js"></script>

datetimepicker2.php:1 Refused to execute script from 'http://raw.githubusercontent.com/xdan/datetimepicker/master/jquery.datetimepicker.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

2 해결방법[ | ]

  • https://raw.githack.com/ 에 가서 URL을 입력하면 CDN 주소로 바꿔줌
  • 또는 아래와 같이 수동으로 URL을 바꿔도 사용 가능하나 이경우 업데이트가 제때 안될수 있음
https://github.com/xdan/datetimepicker/blob/master/jquery.datetimepicker.css
https://rawcdn.githack.com/xdan/datetimepicker/master/jquery.datetimepicker.css
  • 브랜치가 아닌 특정 커밋, 태그 등 불변하는 것을 기준으로 링크를 만들어야 안전함
<link rel="stylesheet" href="https://rawcdn.githack.com/xdan/datetimepicker/82a256409f0af54e4d1fd074b312fa579a122d38/jquery.datetimepicker.css">
<script src="/https://rawcdn.githack.com/xdan/datetimepicker/82a256409f0af54e4d1fd074b312fa579a122d38/jquery.datetimepicker.js"></script>

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}