2012-05-04 21 views
3

我正在構建一個使用多個API的Chrome擴展。目前,我已經設置好了,以便我可以使用這些API之一,但嘗試向清單中添加第二個API是行不通的。我嘗試了一些導致擴展不工作或清單文件無效的事情。在Chrome擴展中添加多個外部域

"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'" 

給出無效的明顯錯誤

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

只適用於第一個域

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

給出無效的明顯錯誤

回答

7

只能有一個content_security_policy條目。您可以指定多個域,但你必須給他們的空間,而不是用逗號分隔:

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

欲瞭解更多信息,請參閱CSP specification,特別是examples section

+0

謝謝,傻我沒有想到最簡單的解決方案 –