Monaca Onsen UI Discord Chat Github Repo

jsonp error acccessing LAN resource



  • Good Morning,
    I’m an italian teacher building an educational app for my students.
    I’m quite new here and I’ve tried the following:
    config.xml: row <access origin="*" /> (manually added)
    index.html:

    • <meta http-equiv=“Content-Security-Policy” content=“default-src * data:; style-src * ‘unsafe-inline’; script-src * ‘unsafe-inline’ ‘unsafe-eval’; connect-src *”> (manually added)

    • and: $.ajax({ url: "http://192.168.178.107:5000", jsonp: "jsonpcallback", dataType: "jsonp", type: "get", data: { prodotti: JSON.stringify(prodotti) }, success: function(data){ console.log(data.result); }, error: function(data){ var debug = document.querySelector("#debug").innerHTML = JSON.stringify(data); } })

    cordova-plugin-whitelist: enabled

    I would access LAN server resource http://192.168.178.107:5000. I have no problem using my PC browser, but I always receive the following in the a <div id = “debug”></div> once I try APK generated with Monaca.io:

    {"readyState":4, "status": 404; "statusText": "error"}
    

    I think the problem is on app side because I cannot see any request from my smartphone using WireShark.

    I’m using pro-plan (for this month). What can I do?

    Best Regards,
    Stefano


  • administrators

    Is your device running Android 9? HTTP communication is prohibited on Android 9 so you will need to use HTTPS. Even if you’re not running Android 9, it is worth changing your server HTTPS and trying again.



  • @emccorson said in jsonp error acccessing LAN resource:

    Is your device running Android 9? HTTP communication is prohibited on Android 9 so you will need to use HTTPS

    Thank you for your reply!
    I’ve converted my HTTP server in HTTPS. I’m using Flask and it tells from debug console:

    I’m monitoring my LAN using WireShark but nothing seems to start from my smartphone. Instead I can see all packets generated from another application (I’m using TCP/UDP test tool).

    I can also say that using “Custom Build Debugger” it works correctly. How can I create an operating APK with jsonp without using Custom Build Debugger?