aalises / age-of-empires-II-api

API for Age of Empires II Built with Flask-RESTFul + SQLAlchemy
https://age-of-empires-2-api.herokuapp.com
BSD 3-Clause "New" or "Revised" License
120 stars 31 forks source link

Can't access API from CodeSandbox using Axios #18

Closed juanzitelli closed 3 years ago

juanzitelli commented 3 years ago

I'm trying to use this API to make a simple app in React and TS to show AOEII civilizations. For this purpose I'm using Axios to fetch data, but I can't make it work. I can fetch the data from Postman, Curl, Chrome (pasting the GET url in the search bar) and when I try to make a request from my CodeSandbox App, It throws a Network Error, addressing there's a CORS policy blocking my request, but then how am I capable of fetching that particular data from Chrome, Postman and Curl then? Postman doesn't help either by not telling me which headers it uses to send the request.

I'm getting a 502 Network Error that looks like this:

/s/youthful-browser-mx5ix?file=/src/App.tsx:307-319:1 Access to XMLHttpRequest at 'https://zqixi-lsp.sse.codesandbox.io/socket.io/?type=go-to-definition&EIO=3&transport=polling&t=NTzf459' from origin 'https://codesandbox.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

juanzitelli commented 3 years ago

https://codesandbox.io/s/youthful-browser-mx5ix?file=/src/App.tsx Here's the example

aalises commented 3 years ago

Cannot access the codesandbox @juanzitelli :( ... you could try setting the Access-Control-Allow-Origin: * header on the axios request though...

juanzitelli commented 3 years ago

Sorry! I deleted it, I'll create a new one and try again! And I'll let you know if that solves the issue :)

aalises commented 3 years ago

Did you manage to fix it @juanzitelli ?