Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Enable CORS on API #56

Closed
Baadier-Sydow opened this issue Mar 21, 2020 · 3 comments
Closed

[BUG] Enable CORS on API #56

Baadier-Sydow opened this issue Mar 21, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@Baadier-Sydow
Copy link

Describe the bug
Retrieving data from the API programmatically from localhost throws CORS exceptions.

Access to XMLHttpRequest at 'https://covid-za-api.herokuapp.com/cases/confirmed' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to retrieve data programmatically
  2. Data retrieval from API fails because of CORS

Expected behavior
Expect to be able to retrieve data from the API.

Screenshots
Screen Shot 2020-03-21 at 7 33 51 PM

@Baadier-Sydow Baadier-Sydow added the bug Something isn't working label Mar 21, 2020
@vukosim
Copy link
Member

vukosim commented Mar 21, 2020

Thanks, @vt-riq please take a look.

@vutlhari
Copy link
Contributor

@Baadier-Sydow this should be fixed now. Please confirm.

cc @vukosim

@AnrichVS
Copy link

I can confirm that the CORS header is now sent correctly. A simple test can be performed by serving the below HTML file using Python's SimpleHTTPServer for example:

covid19za_56_test.html

<html>
<head>
	<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
    		    $.get('https://covid-za-api.herokuapp.com/cases/confirmed?province=GP', function(data){
    			$('#data').html(JSON.stringify(data));
    		    });
		});
	</script>
</head>
<body>
	<p id="data"></p>
</body>
</html>

When navigating to http://localhost:8000/covid19za_56_test.html, the response received contains the Access-Control-Allow-Origin: * header, and the data is retrieved successfully.

@vukosim vukosim closed this as completed Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants