i'm developing a web app sharing a resource between multiple clients . after a fair amount of time searching over the web i chose token based authentication and decided to go with it .
i used AngularJS / interceptors on the clint side to add the token to request header
if ($localStorage.token) {
config.headers.TOKEN = $localStorage.token;
}
...
//
return config ;
and on the server-side , a Flask application using flask-cors to handle Cross origin requests . now the problem is that ever since i added the interceptors part , all request are send as OPTIONS ( regardless of the original method - $http.post() or .. )
i read a similar question but the answer was focused on express and i couldn't manage to fix it here . here is my cors configuration :
cors = CORS(application, resources={r"/api/*": {"origins": "*"}}, allow_headers=['X-Requested-With', 'Content-Type', 'TOKEN', 'Accept'])
other than fixing it , why is this happening ? what role is this OPTIONS Request playing in CORS ?