So I'm currently working on a simple React app that makes fetch requests to the reddit JSON api (e.g. https://reddit.com/r/popular.json). In development I used the cors-anywhere demo, as for some reason I believed that the CORS errors wouldn't show up in production.
After doing some research on what CORS actually is, my understanding is that these errors are due to the Reddit JSON api not allowing requests from my domain. However, I've seen relatively recent videos of people making similar apps with no CORS problems mentioned, so I was wondering if anybody experienced with the Reddit APIs could help me figure out the easiest fix for here. My understanding is that the most foolproof method is to set up my own node server to make the request and then return it to my app with the proper CORS headers. But then I would have to host the server, let alone learn how to write it, which is not ideal. I was hoping there's an easier fix like adding my domain name to a whitelist on Reddit, or switching to the regular api instead of the JSON one. Let me know if there's anything I can do! Thanks.
btw, the app is hosted here: https://moburu.github.io/simplereddit
reddit.com doesn't set CORS headers. Try api.reddit.com.