When I attempt to send a $http POST
request to a server API, the request method unexpectedly changes to OPTIONS
. Strangely, this issue only occurs when working with localhost. To troubleshoot, I tried making the same request using Postman and it worked flawlessly.
Service:
function httpReg(userData) {
console.log(userData)
return $http({
method: 'POST',
url: CONFIG.APIHost + '/auth/signup',
data: {
"username": userData.username,
"email":userData.email,
"password": userData.password
},
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
});
}
Screenshot:
https://i.sstatic.net/Zx6ze.png
(source: joxi.net)