JeremyTsaii/leetcode-stats-api

Error 503 is thrown due to CORS policy

Opened this issue · 0 comments

Steps to reproduce

  1. Create a simple web application with https://leetcode-stats-api.herokuapp.com/<username> call inside.
  2. Host it in GitHub pages.
  3. Open it in browser

Expected behavior
Call should be valid and 200 status code should be returned with response body.

Actual behavior
503 error is returned and the following error is printed in console:

Access to fetch at 'https://leetcode-stats-api.herokuapp.com/johndoe' from origin 'https://johndoe.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Recommendation for fix
Allow CORS requests from https://*.github.io.