This is a migrated thread and some comments may be shown as answers.

OPTIONS 405 Not Allowed, even with Chrome App extension

3 Answers 943 Views
AppBuilder in-browser client
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raul Arturo
Top achievements
Rank 1
Raul Arturo asked on 05 Jun 2015, 01:19 AM

Hello!

 I've been trying to solve this problem for days, but can't. I'm trying to do an hybrid app, using jQuery AJAX POST requests to an external service. But no matter what I do, I keep receiving a "OPTIONS http://xxxx 405 (Method Not Allowed)". I installed the Chrome App extension for Telerik, but the error just don't go away. If I try the same data sent to the service in the Rest Console Chrome App, it works perfectly. It even works great as a packaged Chrome App, but can't make it work on the Telerik AppBuilder iPhone simulator on Chrome. This is my AJAX code:

 

$.ajax({
    url : defaultURL + metodo,
    type: "POST",
    contentType : "application/json",
    data:datos
}).
success(function (data){
   callback (null, data);
}).
error(function (data){
   callback (data, null);
});

 

I've tried to send crossDomain request, tried to send the data with JSON.stringify, but nothing. And what I receive in the chrome dev console is this:

OPTIONS http://xxxxxxxx 405 (Method Not Allowed)

XMLHttpRequest cannot load http://xxxxxxx. Invalid HTTP status code 405 

{readyState: 0, status: 0, statusText: "error"}

 

BTW: I can't modify the external service, it is from a third party and not available for me.

Any suggestions? I really like the Telerik AppBuilder in the cloud, but I'm starting to get desperate and even thinking in returning to the Chrome packaged App if I can solve this problem :(

3 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 09 Jun 2015, 04:58 PM
Hello Raul,

The In-Browser AppBuilder Device Simulator is making requests from the client's browser and it is therefore a subject to CORS. This means that CORS should be enabled on the requested server and specifically, the requested server should return a CORS header that informs the client's browser that it allows it to make requests.

During the preflight OPTIONS request, you should see the following two headers: Access-Control-Request-Method and Access-Control-Request-Headers. These request headers are asking the server for permissions to make the actual request. Your preflight response needs to acknowledge these headers in order for the actual request to work. In case the server is not configured to accept this request method, it will respond with a "405 Method Not Allowed". As a result the Chrome App CORS extension cannot add the Access-Control-Allow-Origin header and the error you posted will be received when working with the device simulator in the browser.

Since you cannot modify the server to add the Access-Control-Allow-Origin header in its configuration, you can try sending a GET request. GET might be enabled as a type and it might be worth checking. Alternatively you can try the Windows client of AppBuilder or the Command-Line Interface. Both provide a device simulator which is not running inside the browser and you should not have CORS issues.


Regards,
Tina Stancheva
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Raul Arturo
Top achievements
Rank 1
answered on 12 Jun 2015, 12:08 PM
I ended up using the command line, because I don't have windows, I use linux and osx, and the command line was pretty good after doing some examples. Thanks!
0
Gaurav
Top achievements
Rank 1
answered on 29 Mar 2018, 07:01 AM

in order to solve this 

 

chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security 

use the above command to get a chrome instance , i dont know hoe but it works

Tags
AppBuilder in-browser client
Asked by
Raul Arturo
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Raul Arturo
Top achievements
Rank 1
Gaurav
Top achievements
Rank 1
Share this question
or