Configuring CORS whitelist
Manage Allowed Origins for your DataHub Apps to prevent CORS errors
What is CORS?
Cross-Origin Resource Sharing (CORS) is an HTTP-header-based mechanism that allows a server to indicate any other origin (domain, scheme, or port) than its own from which a browser should permit the loading of resources.
Allowed Origins
Access-Control-Allow-Origin headers, Allowed Origins, could have one or many domain addresses that you may whitelist in DataHub to comply with the default DataHub CORS policy: you need to whitelist all domains that could be a part of a cross-origin request.
CORS request example
An example of a cross-origin request: the front-end JavaScript code served from https://domain-a.com
uses XMLHttpRequest to make a request for https://domain-b.com/data.json
. For security reasons, browsers restrict cross-origin HTTP requests initiated from scripts.
CORS error example
CORS Errors are common when youโre working with APIs and itโs important to handle them effectively due to security reasons.
Add Allowed Origin
Navigate to your App settings.
In the Allowed Origins section, add a domain address, that includes protocol, hostname, and optionally port. Example:
http://localhost:9000
orwss://uniswap.org
.Click Save and save your changes to the Allowed Origins list. If you see errors upon saving you need to fix them first and click Save to revalidate and save.
Delete Allowed Origin
Navigate to your App settings.
In the Allowed Origins section, delete a domain address.
Click Save and save your changes to the Allowed Origins list.
Last updated