Cordova - Refused to connect to api from device (Content Security Policy)

后端 未结 1 328
执念已碎
执念已碎 2021-01-20 07:22

I am working with Visual Studio\'s Tools for Apache Cordova.

When I build the app with Ripple, all is well. But when I build it to my android device, the app refuses

1条回答
  •  离开以前
    2021-01-20 08:05

    From the Error Message. You are calling Ajax Request in your JS. But you only added http://XXX.herokuapp.com after script-src, which only allows loading the script content. To allow the Ajax request, http://XXX.herokuapp.com needs to be added after connect-srclike this:

    
    

    Alternatively, you can add the URL after default-src, which sets a default policy for allowing everything(loading script/CSS contents,Ajax Request and so on). So the meta Tag should be like this:

    
    

    For detailed information about Content Security Policy you can refer to Content Security Policy Reference.

    0 讨论(0)
提交回复
热议问题