fix(cors): allow Idempotency-Key header for the jobs API - #198
Merged
Conversation
…the jobs API The jobs-API admit handlers (`POST /api/jobs/mint`, `POST /api/jobs/send`) require the `Idempotency-Key` request header (`read_idempotency_key`). A browser sending that header triggers a CORS preflight (OPTIONS), but the router's `CorsLayer` only allowed `Content-Type` in `Access-Control-Allow-Headers`. The preflight therefore failed and the web frontend could not mint or send. Add `idempotency-key` to the CORS `allow_headers` list so the preflight succeeds. `HeaderName::from_static` requires the lowercase form. Cover the fix with a CORS preflight test (`OPTIONS /api/jobs/mint` with `Access-Control-Request-Headers: idempotency-key`) asserting the response echoes both `idempotency-key` and `content-type` in `Access-Control-Allow-Headers`.
TaprootFreak
marked this pull request as ready for review
June 3, 2026 22:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The jobs-API admit handlers (
POST /api/jobs/mint,POST /api/jobs/send) require theIdempotency-Keyrequest header (read_idempotency_key). When a browser sends that header it first issues a CORS preflight (OPTIONS). The router'sCorsLayeronly listedContent-TypeinAccess-Control-Allow-Headers, so the preflight was rejected and the browser blocked the request — the web frontend could not mint or send.Fix
Add
idempotency-keyto the CORSallow_headerslist increate_router(node/src/router.rs).HeaderName::from_staticrequires the lowercase form. Minimal change, no scope creep.Test
New CORS preflight test in
node/src/router_tests.rs: sendsOPTIONS /api/jobs/mintwithOrigin,Access-Control-Request-Method: POSTandAccess-Control-Request-Headers: idempotency-key, then asserts the response'sAccess-Control-Allow-Headersechoes bothidempotency-keyandcontent-type(case-insensitive). TheCorsLayeranswers the preflight itself.Local verification
cargo fmt --all -- --check: cleancargo clippyall three feature scopes (-p node -p shared,-p node --all-features, program+prover--lib) with-D warnings: cleancargo llvm-cov nextest --release -p node -p shared --all-features ... --fail-under-lines 100 --fail-under-functions 100 -E 'not binary(api_remote)'): exit 0 — 443/443 tests passed;router.rslines 100%, functions 100%