aurelia / http-client

A simple, restful, message-based wrapper around XMLHttpRequest.
MIT License
62 stars 59 forks source link

HTTP POST turns into OPTIONS if .withHeader('Content-Type', 'application/json') is specified. #146

Closed ignusk84 closed 8 years ago

ignusk84 commented 8 years ago

I have the following request:

            that.http.createRequest("User/Create")
                .asPost()
                .withHeader('Content-Type', 'application/json')
                .withContent(model)
                .send()
                .then(response => {
                    console.log(response.response);
                }).catch(err => {
                    console.log(err);
                });

When looking at fiddle, I expect the request to have a POST verb, instead, this is what I am seeing:

OPTIONS http://domain.com/User/Create HTTP/1.1 Host: domain Connection: keep-alive Access-Control-Request-Method: POST Origin: http://localhost:4400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Access-Control-Request-Headers: content-type Accept: / Referer: http://refer.com Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8