DEV Community

Cover image for What is CORS and How to handle it?
Raksha for Canopas Software

Posted on

What is CORS and How to handle it?

Do you know what is CORS and how to fix CORS errors?

CORS restricts any clients(domains) get access to your server!

All modern browsers are honest enough and handle such a situation themselves. Especially if we’ve integrated js in our code, the browser will never allow us to access the cross-origin requests unless we allow it!

When working on the application, whose backend and frontend rely on different origins, we will be forced to configure CORS headers.

Appropriately setting CORS will save you from security vulnerabilities at an earlier stage.

Also, enabling appropriate CORS allows us to set and get custom request/response headers.

Dangerous-looking CORS errors are actually dangerous for unauthorized clients and saviors for us!

For detailed implementation, check out original post.

Top comments (1)

Collapse
 
sloan profile image
Sloan the DEV Moderator

Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link. Doing so helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section.

If you choose to do so, you also have the option to add a canonical URL directly to your post.