I have seen in many places that one of the benefits of token-based authentication
over cookie-based authentication
is it is better suite for CORS/cross-domain scenario.
But why?
Here is a CORS scenario:
An HTML page served from http://domain-a.com makes an
<img>
src request for http://domain-b.com/image.jpg.
Even if there's a token on my machine, how could the mere <img>
tag know where to find and send it?
And according to here, it is suggested to store JWT as cookie, so how could that survive the CORS/cross-domain scenario?
ADD 1
Token-based authentication is easier to scale out than session-cookie one. See a related thread here: Stateless web application, an urban legend?