Reputation: 10818
I am building a RESTfull API
with express
.
Is there any cases I might need to plug https://www.npmjs.com/package/cors library you can thing of? For what particular scenarios would you use CORS
with RESTfull API
?
Upvotes: 0
Views: 49
Reputation: 3605
You need CORS when the API is accessed from browsers on a website domain that is different from the API domain. So probably, yes you need to support CORS.
You do not need CORS support if the API is not accessed from a browser.
You do not need CORS support if the API is on exactly the same domain (and port) as the website accessing the API.
Upvotes: 1