javascript - Content Security Policy not working for Ionic serve -
in index.html
have meta tag:
<meta http-equiv="content-security-policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
when run ionic serve
(ionic version 1.6.1) following error:
refused load script 'http://localhost:35729/livereload.js?snipver=1' because violates following content security policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' http://localhost:8100"
does knows how fix this?
i noticed, have set script-src
self
means scripts load domain same origin (host name).
your port number changed when run on web server because chooses randomly selected port run application. not have knowledge ionic
server csp
, can conclude that.
in case, localhost:35729
, localhost:8100
not same policy header blocks loading of script.
to fix this, better use host name app. in addition, csp
works better if send through http response header
rather in meta
tag. please let me know if have doubt.
Comments
Post a Comment