WebView Content Security Policy

Alvaro Jose Rios Chaustre picture Alvaro Jose Rios Chaustre · Jul 9, 2016 · Viewed 10k times · Source

I want to load a video from Vimeo in a WebView. It works, but the preview image doesn't load and I get this error:

I/chromium: [INFO:CONSOLE(0)] "Refused to load the image 'android-webview-video-poster:default_video_poster/-5228946977756841864' because it violates the following Content Security Policy directive: "img-src https://i.vimeocdn.com https://secure-b.vimeocdn.com https://f.vimeocdn.com https://vimeo.com https://sb.scorecardresearch.com https://ssl.google-analytics.com https://secure.gravatar.com https://i0.wp.com https://i1.wp.com https://i2.wp.com". ", source: https://player.vimeo.com/video/172374044 (0)

How can I fix it?

Answer

n33x picture n33x · Nov 3, 2016

Add the following to Content-Security-Policy meta tag img-src directive:

android-webview-video-poster:

As in:

<meta http-equiv="Content-Security-Policy" content="default-src * gap:; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src *; img-src * data: blob: android-webview-video-poster:; style-src * 'unsafe-inline';">