CORS policy doesn't match API documentation - browser clients from other origins are blocked #6
Labels
No labels
bug
contribution welcome
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
tom79/Holos-Discover#6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi! I am trying to utilize the public API (no token).
The API documentation (doc/api.md, line 746) states:
codeberg.org/tom79/Holos-Discover@d9e71c0f07/doc/api.md (L746)But the actual implementation in src/server.ts (lines 53-59) restricts CORS to only the instance's own publicUrl in production:
codeberg.org/tom79/Holos-Discover@d9e71c0f07/src/server.ts (L52-59)This means any browser-based client on a different origin gets a CORS error when trying to use the API, even though the docs say all origins are allowed.
Based on the documentation, browser requests from any origin should be accepted - making the API usable from third-party web apps and search galleries.
Suggested fix
Change the production origin to '*' to match the documented behavior, or update the docs to reflect the actual restriction.
Sample Code
This came to my attention because I have been working on a cross platform photo gallery site (client side code) for awhile now. It currently has adapters for Mastodon, Lemmy, PieFed, Vernissage, and Bluesky visible for end users.
Tonight I added my work for Holos, but after getting to a point I could try it, I was seeing CORS errors popping up.
Here's the gallery link:
https://gts.scoobysnack.net/gallery
Currently the only way to get the Holos adapter to initialize is with a query string parameter (no front end UI at this point)
https://home.scoobysnack.net/gallery/?adapter=holos&tag=photography
Which throws this in the console.
Thanks!