Submitting a run through the API through the web console
1 year ago

I would like to know how to submit a run through the API with plain Javascript though the web browser's console. When I use: "fetch("https://www.speedrun.com/api/v1/runs", { method: "POST" , headers: {"X-API-Key":"NotARealKey1234"}});" I immediately get the error: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.speedrun.com/api/v1/runs. (Reason: header ‘x-api-key’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response)." However, when I exclude the header: "fetch("https://www.speedrun.com/api/v1/runs", { method: "POST" });" I get the 403 forbidden response for not including user context. So, how am I supposed to give the user context?

New Jersey, USA

you're making it way too complicated ...

Edited by the author 1 year ago
Somerset, England

Post requests in the api don't work in the browser, they're blocked by a CORS policy. You need to run your code in a different context

Edited by the author 1 year ago
Gaming_64, diggity, and Ivory like this
New Jersey, USA

@jackzfiml ok.. don't care... i can post when and what i want lmao

Iowa, USA

I mean, not really. If you post something that angers the community then you can get banned and won’t be able to post for a while meaning you can’t post want you want.

YUMmy_Bacon5, MineGG and 2 others like this
New Jersey, USA

u believe what you want to believe

Edited by the author 1 year ago