Modernizr Causes Content Security Policy (CSP) Violation Errors

前端 未结 2 1836
一个人的身影
一个人的身影 2020-12-25 11:11

I am attempting to use the new Content Security Policy (CSP) HTTP headers on a test site. When I use CSP in conjunction with Modernizr I get CSP violation e

2条回答
  •  萌比男神i
    2020-12-25 11:36

    I found a fix without having to use unsafe-inline.

    You can modify the unminimized Modernizr at one line:

    fakeBody = body || document.createElement('body');
    

    convert to

    fakeBody = document.createElement('body');
    

    works on IE9, Firefox, and Chrome.

提交回复
热议问题