Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cookies not sent on OPTIONS requests

For an Angular 1 app I am working on, cookie authentication is used. The problem is: when making OPTIONS calls, cookies are not sent and the server tries to redirect user to login again. Just wondering, whose "fault" is it? Server (Azure API Apps) or frontend? If frontend, how do I send cookies on OPTIONS call? I am using augular-resource and have configured it as below:

$httpProvider.defaults.withCredentials = true

like image 939
Jiew Meng Avatar asked Jan 20 '17 09:01

Jiew Meng


Video Answer


1 Answers

The specification says:

Otherwise, make a preflight request. Fetch the request URL from origin source origin using referrer source as override referrer source with the manual redirect flag and the block cookies flag set, using the method OPTIONS, and with the following additional constraints … Exclude user credentials.

and also

The term user credentials for the purposes of this specification means cookies, HTTP authentication, and client-side SSL certificates that would be sent based on the user agent's previous interactions with the origin. Specifically it does not refer to proxy authentication or the Origin header.

So the client should not send cookies, and the server should be able to respond to the preflight request without requiring authentication to take place first.

like image 101
Quentin Avatar answered Sep 22 '22 06:09

Quentin