indomie858 / flygames

FlyGames React Website
1 stars 0 forks source link

[API] Homepage: list 10 (or so) of the most popular games #2

Closed dpalencia closed 3 years ago

dpalencia commented 3 years ago

We ran into a CORS issue when trying to query the IGDB API from the React app.

Upon investigation, it looks like we need to set up a proxy URL to make requests to. Details here: https://api-docs.igdb.com/#proxy

dpalencia commented 3 years ago

I went ahead and deployed a Node.js server on a Heroku container that adds the necessary Access-Control-Allow-Origin header to API requests. This is the URL:

https://flygame-igdb-proxy.herokuapp.com/

Now all we need to do to make API requests is put the Heroku address before the IGDB endpoint. For example,

https://flygame-igdb-proxy.herokuapp.com/https://api.igdb.com/v4/games

We still make requests to the same authentication URL to get an access token (https://id.twitch.tv/oauth2/token) which we can pass to the proxied requests in the same way as per their documentation.

dpalencia commented 3 years ago

Get images as well from the API request.

indomie858 commented 3 years ago

Added field "cover.url" to API request to get images. See pull request #8

indomie858 commented 3 years ago

Screenshot from discord for cover image url sizes image