• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  1. Home
  2. bob0
  3. Posts
B
Offline
  • Profile
  • Following 0
  • Followers 0
  • Topics 1
  • Posts 4
  • Groups 0

Posts

Recent Best Controversial
  • RE: clickable html app: Accesss to XMLHttpRequest from origin 'file://' has been blocked by CORS policy

    @lduboeuf It seems creating a QML container app works better thatn the HTML template method. Thank you for sending the link to your project.

    posted in App Development
    B
    bob0
    3 Nov 2022, 21:04
  • RE: clickable html app: Accesss to XMLHttpRequest from origin 'file://' has been blocked by CORS policy

    When testing with clickable desktop, the app performs AJAX calls without any problem.

    However, when testing on a real device (PinePhone, in my case), AJAX calls are still blocked...

    posted in App Development
    B
    bob0
    3 Nov 2022, 20:43
  • RE: clickable html app: Accesss to XMLHttpRequest from origin 'file://' has been blocked by CORS policy

    @lduboeuf Thank you. It works. Just for my curiosity, was this documented somewhere?

    posted in App Development
    B
    bob0
    3 Nov 2022, 11:53
  • clickable html app: Accesss to XMLHttpRequest from origin 'file://' has been blocked by CORS policy

    Hello,

    I am experimenting with clickable HTML app.
    I am using clickable 7.6.0

    I generate a template using clickable create and I select HTML template.

    Then I try modifying the index.html webpage adding a simple ajax request:

    <script>
    	function run() {
    
    		// Creating Our XMLHttpRequest object
    		var xhr = new XMLHttpRequest();
    
    		// Making our connection
    		var url = 'https://jsonplaceholder.typicode.com/todos/1';
    		xhr.open("GET", url, true);
    
    		// function execute after request is successful
    		xhr.onreadystatechange = function () {
    			if (this.readyState == 4 && this.status == 200) {
    				console.log(this.responseText);
    			}
    		}
    		// Sending our request
    		xhr.send();
    	}
    	run();
    </script>
    

    While this code works opening the index.html file on Firefox, it seems ajax requests are blocked from the webapp-containter. I get this error:

    qml: [JS] (file:///home/bob0/Desktop/testapp/build/all/app/install/www/index.html:0) Access to XMLHttpRequest at 'https://jsonplaceholder.typicode.com/todos/1' from origin 'file://' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
    

    How can I enable the possibility make AJAX request from an HTML app? Is there any setting/policy to be changed?

    Thank you in advance for your help!

    posted in App Development
    B
    bob0
    3 Nov 2022, 07:38