Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome, no response data after OPTIONS request?

Tags:

I'm using CORS to fetch some data from an API. All was working well until Chrome update launched a day ago.

Now after an OPTIONS request the subsequent request always returns with no response data.

If I click a button quickly twice it will show on the second request (the same one) since it's not making the pre-flight call.

I've re-installed and disabled all extensions, no idea what's going on here.

Is anyone else experiencing this?

EDIT note that the no response is directly from the devtools. It's just a n Ajax call. And even though it's not displaying any response data it's all working correctly. For instance if I do a console.log(res) in the code it's all good. It's strictly Chrome not showing any response and strictly following an OPTIONS (CORS) request.

EDIT Also note that everything is working and displaying perfectly fine in Firefox/Firebug.

EDIT Chrome Version 56.0.2924.87 (64-bit)

EDIT I'm just lost here. The app is working perfectly fine so it makes a bit hard to even know where to star debugging. It seemed to happen literally the day after Chrome popped up a green update icon. After that update I was seeing nil.

I checked some of my other apps and actually it works there! So I was thinking it might be related to some combination of plugin/Chrome not playing nicely. I tried reverting back a lot to many versions but not luck. Weird thing is that it's only following an OPTIONS request. I'm guessing it's something simple like an encoding type, but no idea where.

EDIT Also tried following some of the leader here with no luck: View AJAX response content in Chrome developer tools?

EDIT I have been able to narrow this down to an issue with vue-resource plugin. Works fine with axios. Fiddle is here: https://jsfiddle.net/tpnucv5m/

like image 552
Rob Avatar asked Feb 11 '17 05:02

Rob


People also ask

What is preflight in Chrome?

Preflight requests are a mechanism introduced by the Cross-Origin Resource Sharing (CORS) standard used to request permission from a target website before sending it an HTTP request that might have side effects.

Why browser send preflight request?

This pre-flight request is made by some browsers as a safety measure to ensure that the request being done is trusted by the server. Meaning the server understands that the method, origin and headers being sent on the request are safe to act upon.


2 Answers

A quick fix, until the module is updated, is to comment out this line in dist/vue-resource.common.js:

xhr.responseType = 'blob';

It should be somewhere around line ~1054

like image 155
Ibrahim Avatar answered Sep 19 '22 06:09

Ibrahim


I know this is not a solution (do not upvote), but right click the OPTIONS XHR and REPLAY XHR. It will resend the Ajax call and now there will be an answer.

I presume there is some async issue with the plugin.

like image 40
SNEILΛ Avatar answered Sep 21 '22 06:09

SNEILΛ