RetroAchievements / RetroAchievements/api-js

CORS error when using from frontend

Open
#108 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/cannot-reproduce
Dominant language
TypeScript
Stars
77
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I get a CORS error (preflight OPTIONS request fails) when I try to use the library from a frontend app.

I created a minimal setup project here https://github.com/makmonty/ra-bug-min-rep

Note: I don't get the error if I do the same requests with my own implementation as such:

const result = await fetch('https://retroachievements.org/API/API_GetGame.php?y=<webApiKey>&z=<username>&i=<gameId>')
const data = await result.json()

So it's not a configuration issue at the API side.

My environment is:

Browser: Firefox 131.0
SO: Arch Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal setup project and reproduce the failed preflight OPTIONS request in Firefox. Compare the library request with the direct fetch example in the issue, then trace the library entry point used by the frontend. Done means the frontend can make the same request without a CORS preflight failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.