Sergino
Sergino

Reputation: 10818

Do I need to use CORS in case of RESTfull API?

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

Answers (1)

Steve Campbell
Steve Campbell

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

Related Questions