As I understand, a pre-flight request is sent by the browser if any of the following conditions is false (source: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests):
- Request method is GET, HEAD or POST.
- Custom headers are not set.
- Content-Type header value is either
application/x-www-form-urlencoded
,multipart/form-data
ortext/plain
.
I have a web app which sends a GET request to a server on a different origin. Since I have to send cookies to the server, the property withCredentials
is set to true
. The header Content-Type
is set to application/json
. For this request, the browser does not trigger a pre-flight request, but it should because the third condition is false. What could be the reason behind this? Does it have anything to do with the insignificance of Content-Type
header for a GET request (since there is no request body)?
EDIT: Adding request code:
configObject = {
'withCredentials': true,
headers: {
'Content-Type': 'application/json'
}
};
function getRequest(url, dict) {
$http.get(url, Object.assign({}, configObject)).success(function(result) {
// on success
}).error(function(err) {
// on error
});
// return
}