The discussion revolves around accessing the Discourse APIs from a React app, with users encountering CORS policy issues.
Initial issues arose with fahadaslam98 when trying to call the Discourse APIs due to the API-key header being blocked by CORS policy. Arkshine suggested the correct header should be User-Api-Key.
Later, fahadaslam98 faced another issue with the api-username header being blocked. Arkshine pointed out the correct headers for the Admin API, while gassim noted that for public JavaScript clients, the Admin API is not allowed and the User API should be used instead.
However, RGJ suggested that if the desired data is publicly available, configuring CORS should be sufficient, and API keys would not be needed. This solution was confirmed by gassim, who linked to a relevant discussion and suggested removing API keys from the headers if CORS is properly configured.
Getting the above issue when I am trying to call the discourse APIs. I have already added an SSL certificate to my servers. I am adding the CORS options present on my admin panel but still getting this issue.
Has anyone faced something like this and could help me what is the way out of this???
I think for public Javascript clients, admin api is not allowed (sadly, this complicates everything, I know!) But you’re going to have to use User API keys specification instead.
For me, I’m still trying to figure out how as well. I just want to pull a .json response that’s publicly available.