Adding multiple external domains in chrome extension

google-chrome, google-chrome-extension, javascript

Solution

There can be only one `content_security_policy` entry. You can specify multiple domains but you have to separate them by spaces and not by commas:

"content_security_policy": "script-src 'self' https://domain-1.com https://domain-2.com; object-src 'self'",

For more information see CSP specification, in particular the examples section.

Problem

I'm building a Chrome extension, which uses multiple APIs. Currently I have it set up so that I can use one of these APIs, but trying to add a second to the manifest won't work. I tried a couple of things resulting in either the extension not workin or the manifest file being invalid. ``` "content_security_policy": "script-src 'self' https://domain-1.com; object-src 'self'", "content_security_policy": "script-src 'self' https://domain-2.com; object-src 'self'" ``` Gives invalid manifest error ``` "content_security_policy": "script-src 'self' https://domain-1.com; https://domain-2.com; object-src 'self'", ``` Only works for the first domain ``` "content_security_policy": "script-src 'self' https://domain-1.com, https://domain-2.com; object-src 'self'", ``` Gives invalid manifest error

Original source