Ionic + Angular POST request return state 404

后端 未结 4 1030
忘了有多久
忘了有多久 2020-12-14 19:09

I just updated on the new version on the Angular + Ionic and method for processing remote request stopped working and returns always 404 response.

Request is

4条回答
  •  旧时难觅i
    2020-12-14 20:15

    Hum, I just ran into the same problem: the header suggests it has been fetched from cache... But actually, it seems it has to do with a new security policy in new versions of Cordova.

    Here's how I solved it:

    I installed Cordova's whitelist plugin :

    cordova plugin add cordova-plugin-whitelist
    

    Then, add your content policy in your index.html as a meta tag (using your own host or '*' for accepting all requests) :

    
    

    default-src is used for general requests; the ws://localhost:35729 host is used for live-reload in ionic serve.

    script-src is used for secure script execution

    unsafe-inline and unsafe-eval are required in order for angular to work properly.

    data: gap: https://ssl.gstatic.com is only used on iOS.

    self means the current host of the index.html file.

    You'll have to add your own in order for your requests to work. Don't forget to add the protocol and the port if they're non-standard

    You can skip the meta tag if you don't want it, but you'll get a lot of warnings from the whitelist plugin.

    More info on how to configure this in the plugin's readme.

    Then rebuild your app, and it should work again.

提交回复
热议问题