Skip to content

Fix cross-origin requests answering 500 instead of being denied - #638

Merged
bnolan merged 1 commit into
cryptovoxels:mainfrom
ryanio:fix-cors-500-on-disallowed-origin
Aug 22, 2026
Merged

Fix cross-origin requests answering 500 instead of being denied#638
bnolan merged 1 commit into
cryptovoxels:mainfrom
ryanio:fix-cors-500-on-disallowed-origin

Conversation

@ryanio

@ryanio ryanio commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

A request carrying an Origin header from outside the allowlist answers 500,
on every route, static assets included.

curl -s -o /dev/null -w '%{http_code}\n' https://www.voxels.com/models/avatar.glb
200
curl -s -o /dev/null -w '%{http_code}\n' -H 'Origin: https://example.com' https://www.voxels.com/models/avatar.glb
500

The origin callback in server/server.ts hands cors an Error for an origin
it does not allow. The middleware passes that to next(err), so the request
fails rather than being answered without the header. callback(null, false) is
the deny: the response goes out as normal and the browser blocks the read
itself, which is what the allowlist was for.

Same for /animations/*.glb and every JSON route, so a third-party page cannot
tell a blocked read from a broken server, and error tracking sees 500s that are
not.

Checked with prettier, tsc --noEmit --project tsconfig.precommit.json (no new
errors) and pnpm test (129 green). Happy to check the built branch against
womp.world, which reads this API in production, before it ships.

Handing the cors middleware an Error sends it to next(err), so every
cross-origin request from a site outside the allowlist answers 500 for
every route, static assets included. Denying the header instead lets the
response through and leaves the browser to block it, which is what the
allowlist was for.
@bnolan
bnolan merged commit f3e256e into cryptovoxels:main Aug 22, 2026
1 check passed
@ryanio
ryanio deleted the fix-cors-500-on-disallowed-origin branch August 22, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants