Skip to main content

Troubleshooting CORS Errors

CORS Errors are common when you're working with APIs but it's very important to handle them effectively due to several security reasons.

DataHub supports "Allowed Origin" functionality which allow users to whitelist their specific domains to be a part of a cross-origin request. You can read more about Allowed Origins functionality HERE

Apart from "Allowed Origins" there are two major ways to not expose your API keys and credentials on the Client-Side.

  1. Use a proxy - One solution for making cross-origin requests is to use a CORS proxy to make it seem as though you're making the request from a location that's allowed.

    There are multiple CORS proxies out there that you can use for free. Some examples are as follows -

  2. Use a serverless function - Using a serverless function is another more effective way to handle the CORS errors and proxy our requests and here in this we build our own functions or micro-infrastructure to call a web service and interact using APIs. Azure, AWS & GCP are most popular for running serverless functions.

    Sharing some examples of serverless functions built and shared by our community members.

References

  1. Mozilla MDN Web Docs
  2. Big Commerce Developer Blog