Phonegap Cordova Ajax requests 404 (Not Found) Error

后端 未结 5 2085
悲哀的现实
悲哀的现实 2020-12-02 14:11

My cordova version is 5.0.0

I am getting a 404 error for the all ajax request made when the app is deployed on the device. On the web browser, it wo

相关标签:
5条回答
  • 2020-12-02 14:33

    It should actually add the cordova whitelist plugin :

    cordova plugin add cordova-plugin-whitelist
    

    or in your config.xml file :

    <plugin name="cordova-plugin-whitelist" spec="1" />
    

    but if you are using the online phonegap build service the syntax is different. You have to add the following line in your config.xml file :

    <gap:plugin name="cordova-plugin-whitelist" source="npm" />
    

    and authorize cross domain requests :

    <access origin="*" />
    <allow-intent href="*" />
    <allow-navigation href="*" />
    

    This is not recommended because a wildcard is used everywhere and everything is permitted. But it is perfect for your tests.

    0 讨论(0)
  • 2020-12-02 14:37

    I had the same issue and had to install the cordova-plugin-whitelist

    cordova plugin add cordova-plugin-whitelist
    

    Credit goes to this stackoverflow article - Ajax Command to request URL no longer working

    0 讨论(0)
  • 2020-12-02 14:45

    My problem was a bit different. I compiled the app using a CI pipeline. So, you still need to do all the above (install the whitelist and add internet permission)

    and you also need to find a Visual Studio version that will build the app correctly. Mine doesn't give an error when building, but the resulting app can't make any ajax request

    After I downgraded to VS2017, it works

    0 讨论(0)
  • 2020-12-02 14:47

    This worked for me. The only difference is in my config.xml I had to put it in an node for it to take effect.

    My example below:

    <platform name="android">
        <allow-intent href="market:*" />
        <access origin="*" />
        <allow-intent href="*" />
        <allow-navigation href="*" />
    </platform>
    
    0 讨论(0)
  • 2020-12-02 14:56

    Phonegap User. Adding this line into the config.xml is the solution for me:

    <gap:plugin name="cordova-plugin-whitelist" source="npm" />
    
    0 讨论(0)
提交回复
热议问题