Vue-resource: Why are my post requests sended twice?

Created on 19 Aug 2016  ·  11Comments  ·  Source: pagekit/vue-resource

I send post request like:
Vue.http.post(url, {}, {params:data}).then(callback)
I make the second param in post method a empty object because I don't want to send JSON data.
In chrome's devtool, I record the network data, and I notice that there are two requests sended when I called post method. One of them has a 'Request Method' attribute whose value is 'OPTIONS'.

Most helpful comment

That's called a preflight request that allows the server to specify what is required for that request to be fulfilled.

It's CORS related and is not an issue.

All 11 comments

I suspect these are cors server problems...

I think it's not. I have added the 'Access-Control-Allow-Origin' attribute to response header and after using jquery instead of vue-resource, everything is ok.

That's called a preflight request that allows the server to specify what is required for that request to be fulfilled.

It's CORS related and is not an issue.

@zipoopiz As many have mentioned this is a non issue and is a browser made request to check CORS.

Please use our forum or Gitter if you require anymore help.

This issue will now be closed.

Thanks.

Is there any explanation for as to why the pre-flight request also registers as a normal request to the server and overall the process of sending a request to the server via Vue JS method registers as 2 requests on the server and a request sent via jQuery ajax or separately via Postman registers as 1 request?

@devbirBrst The pre-flight request should be an OPTIONS request which is used to figure out what the server is capable of.

Postman still makes this request, it's just done transparently.

As previously stated, this is not an issue and is in fact expected behavior for any client making HTTP requests.

I am having the same issue. I understand the comments above, but I am sending out Twilio SMS texts in my POST request, and I don't want them sent twice. What does one do to avoid that?

I am having the same issue as well with @robertjoellewis (request duplication)

On the server check if the request method is OPTIONS to not send SMS or whatever.

I have the same problem

I have the same problem of duplicated requests when using jenkins, when I've put jenkins behind Cloudflare. Now, after connecting ezoic, I started to have duplicated requests from my main page. (Not all of the requests and each day is different :P figure that out....)

Now, here's a possible answer:

http://geek.starbean.net/?p=393

"Following that symptom with Google I chanced upon a blog that highlighted HTTP 1.1 RFC 8.2.4.

If an HTTP/1.1 client sends a request which includes a request body, but which does not include an Expect request-header field with the “100-continue” expectation, and if the client is not directly connected to an HTTP/1.1 origin server, and if the client sees the connection close before receiving any status from the server, the client SHOULD retry the request."

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Creabine picture Creabine  ·  3Comments

facesea picture facesea  ·  5Comments

yozman picture yozman  ·  6Comments

christophwolff picture christophwolff  ·  6Comments

Jigsaw5279 picture Jigsaw5279  ·  5Comments