HathorNetwork / hathor-explorer-service

MIT License
1 stars 3 forks source link

Fix CORS problem due to API GW caching #130

Closed lucas3003 closed 2 years ago

lucas3003 commented 2 years ago

Description

If the user access https://explorer.hathor.network, it will work normally. However, if after that the user tries to access https://explorer.mainnet.hathor.network he/she will see a CORS problem. This happens because the first request is cached and returned on the second request. The browser identifies that the Origin in the request is different than the Access-Control-Allow-Origin in the response and shows the CORS error message to the user.

To solve that, the Origin was introduced as a cache key on node_api_get_version endpoint, which is the API that is returning CORS error.

Testing

Tests were performed using Postman and deploying a local stack of Explorer Service on AWS. Now, when the origin changes (And matches the Regex), the Access-Control-Allow-Origin returns the correct value.

Acceptance criteria

User must not see CORS error message on any domain that matches the regex.