I’m trying to make a basic HTML page to quickly retrieve a badge’s information, the app itself works, however, it can’t automatically make a GET request to the Roblox Web API, as I get a CORS policy error (No 'Access-Control-Allow-Origin' header is present on the requested resource.).
I get a 200 status code when I input a badge ID, so it’s working, CORS is just blocking the request. Is there a way for me to get around this error? Here’s the main Javascript code that does the request:
It’s been awhile since I’ve done web development, but IIRC, you get that message if the ajax request goes to a different URL (or domain, can’t remember which) than the page that’s requesting it. You are accessing the Roblox website, so you do not have control over the webserver. You can use something called Curl to send a normal HTTP GET request and then parse the result.
I’m pretty sure CURL can only be used in servers. In this case, it would be a static HTML, which is why I’m using the jQuery AJAX, would it still be possible?
Curl is server only. You are running a web server, right? That would be the only way to get around that. You access the page on your sever, then your server launches a curl request o the Roblox server, parses the data, and then sends that data to the client.
You might be able to disable the CORS setting, but I wouldn’t recommend this since it has some very serious security implications.
Due to CORS, Roblox blocks any requests from a browser that is not from Roblox domains, meaning you cannot send a request from JavaScript that is located on a different non-Roblox domain.
I’d suggest proxying all of your API requests through a proxy of some kind which is something I had to do recently.