As part of building up my list of projects, I’m trying to make a meme generator where I will need to make a POST request to an external API in order to retrieve the final version of the meme in the form of a url for the user to be able save/download it.
As far as I know, Github and other platforms do not allow POST requests as they are static hosts. However I am not sending a POST request to my own code - it’s to a third party API. Is that allowed on these platforms? I’ve tried Googling but no luck.
Github pages does not actually care what your app does. Its the user’s browser that usually cares, usually in the form of a CORS error.
It depends on the API your calling. There are public API’s that will allow you to make requests from the client-side regardless of your origin. If an API is setup for client-side access, you shouldn’t run into these CORS errors. However if the API is not setup for client-side access then not only would you run into CORS errors, you could be leaking your sensitive API token (!)
@lasjorg I tested it now - took me 3-4 hours to do so. And it does work
Though it took me 3-4 hours to build a simple input field, generate the meme and send it off. Why is code so long!?!
@bradtaniguchi It’s a public endpoint, anyone can access it even without any API key/tokens. I have dealt with CORS before - very annoying.