playframework - Play framework external Javascript URL syntax -


how use external javascript files in play framework?

i used syntax:

<script src="https://www.gstatic.com/charts/loader.js" type="text/javascript"></script> 

i put in <head> section of main.scala.html.

https://www.gstatic.com/charts/loader.js correct link, doesn't load , status of package (blocked:csp):

status (blocked:csp) (picture1)

headers:

package header (picture2)

local javascript files work fine, example:

<script src="@routes.assets.versioned("javascripts/hello.js")" type="text/javascript"></script> 

csp stands content security policy (see more):
corresponding header defines sources components allowed loaded. usually, default settings default-src: 'self'. means own host allowed source scripts, css, images, etc. in case localhost:9999, local javascript file passed. need add gstatic.com allowed script-src.

thus, configuration needs done in application.conf-file:

play.filters.headers.contentsecuritypolicy = "default-src: 'self'; script-src: 'self' gstatic.com" 

for further information, please visit official documentation.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -