{"id":"XE-0055","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"75","source_url":"https://github.com/xeprotocol/xe/issues/75","reporter_id":25,"title":"api/deploy: public testnet nodes ship the dev CORS origin http://localhost:3000, so the SDK cannot run in a browser (Minor)","area":"node-api","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:19.838703+00:00","updated_at":"2026-11-10T11:38:19.864677+00:00","source_created_at":"2026-10-26T20:11:27+00:00","told_at":"2026-11-10T00:15:36+00:00","status_changed_at":"2026-10-29T14:04:12.734827+00:00","url":"https://bounty.xe.network/XE-0055","body":"- **Suggested tier:** Minor (possibly Medium as an API inconsistency)\n- **Area:** api (CORS), testnet deployment, docs\n- **Tested:** 2026-10-26, nodes report `xe/92d83d1`, repo master `9787859`\n\n## Summary\n\nEvery public testnet endpoint answers with `Access-Control-Allow-Origin: http://localhost:3000`, whatever the request `Origin` is. Browsers therefore refuse every response to any web page not served from exactly `http://localhost:3000`. The SDK README says it \"works in Node and in a browser, on the same code path\" and its examples point at `https://ldn.core.test.network`, so a browser app built from those examples fails on every call.\n\nThe cause is a hardcoded fallback in the node: when `--cors-origin` is not set, the API uses `http://localhost:3000`. The CLI reference on the site says the default is \"(none)\", which contradicts both the code and `docs/api.md`.\n\n## Evidence\n\nCode (`api/handler.go`, master `9787859`):\n\n```go\norigin := h.corsOrigin\nif origin == \"\" {\n    origin = \"http://localhost:3000\"\n}\n```\n\nDocs that disagree with each other:\n\n- `docs/api.md:27`: \"allowed origin is configurable (default `http://localhost:3000`)\"\n- https://test.network/docs/cli, table \"API, UI and operator listeners\": `--cors-origin` default `(none)`\n- SDK README (github.com/xeprotocol/sdk): \"It works in Node and in a browser, on the same code path\", example `new Xe({ client: 'https://ldn.core.test.network', wallet })`\n\nLive headers, request sent with `Origin: https://myapp.example`:\n\n| Endpoint | Status | Access-Control-Allow-Origin |\n| --- | --- | --- |\n| `OPTIONS https://ldn.core.test.network/blocks/send` | 204 | `http://localhost:3000` |\n| `GET https://ldn.core.test.network/node` | 200 | `http://localhost:3000` |\n| `OPTIONS https://ffm.core.test.network/blocks/send` | 204 | `http://localhost:3000` |\n| `GET https://ffm.core.test.network/node` | 200 | `http://localhost:3000` |\n| `OPTIONS https://nyc.core.test.network/blocks/send` | 204 | `http://localhost:3000` |\n| `GET https://nyc.core.test.network/node` | 200 | `http://localhost:3000` |\n| `GET https://test.network/api/v1/health` | 200 | `http://localhost:3000` |\n\n## Steps to reproduce\n\n1. Save the page below as `cors-poc.html`. It calls `GET /node` on the three core nodes and on the test.network proxy.\n2. Serve it from any origin other than `localhost:3000`, for example `python3 -m http.server 8765 --bind 127.0.0.1`, and open `http://127.0.0.1:8765/cors-poc.html`.\n3. Result: all four requests fail with `TypeError: Failed to fetch`, and the console shows a CORS error.\n4. Control: serve the same file with `python3 -m http.server 3000` and open `http://localhost:3000/cors-poc.html`. All four return `OK 200`.\n\n```html\n<!doctype html><meta charset=\"utf-8\"><title>XE CORS PoC</title>\n<pre id=\"out\">running</pre>\n<script>\n// Fetch a public read endpoint from a page whose origin is not http://localhost:3000.\nconst nodes = ['https://ldn.core.test.network/node','https://ffm.core.test.network/node','https://nyc.core.test.network/node','https://test.network/api/v1/node'];\n(async () => {\n  const lines = ['page origin: ' + location.origin];\n  for (const u of nodes) {\n    try { const r = await fetch(u); lines.push('OK ' + r.status + ' ' + u); }\n    catch (e) { lines.push('BLOCKED ' + u + ' (' + e.name + ': ' + e.message + ')'); }\n  }\n  document.getElementById('out').textContent = lines.join('\\n');\n})();\n</script>\n```\n\nObserved with headless Chrome on 2026-10-26:\n\n```\npage origin: http://127.0.0.1:8765\nBLOCKED https://ldn.core.test.network/node (TypeError: Failed to fetch)\nBLOCKED https://ffm.core.test.network/node (TypeError: Failed to fetch)\nBLOCKED https://nyc.core.test.network/node (TypeError: Failed to fetch)\nBLOCKED https://test.network/api/v1/node (TypeError: Failed to fetch)\n\npage origin: http://localhost:3000\nOK 200 https://ldn.core.test.network/node\nOK 200 https://ffm.core.test.network/node\nOK 200 https://nyc.core.test.network/node\nOK 200 https://test.network/api/v1/node\n```\n\n## Impact\n\n- Any browser dApp, explorer or agent UI built on the SDK fails against the public testnet unless it happens to run on `localhost:3000`. The documented browser support does not work in practice.\n- No security impact found: the setting is more restrictive than intended, not less. Reads are public anyway, and writes are signed client side.\n- A side effect worth noting: any page a user runs on `localhost:3000` (a common dev port) is the one origin trusted by every public node.\n\n## Suggested fix\n\n1. Pick an intended default and make the code, `docs/api.md` and the CLI reference agree. For a public read API with no cookies, `Access-Control-Allow-Origin: *` is the usual choice; or default to no CORS header, as the CLI reference claims.\n2. Set `--cors-origin` explicitly on the public testnet nodes.\n3. Optionally allow a list of origins and echo the matching one with `Vary: Origin`.\n\n\n## Relation to existing issues\n\n#70 mentions the fixed `localhost:3000` header in passing, as a reason a third party page cannot read responses. This report is about the header itself as a defect: it breaks the documented browser support of the SDK on every public node, and the CLI reference and `docs/api.md` disagree on the default.\n\n## Payout\n\nXE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc`\n\nThis is an ed25519 address derived as in `core/crypto.go`. Could you confirm it will be valid for the mainnet payout, or tell me if you need a separately designated mainnet address?\n","patch_refs":[{"id":144,"repo":"xeprotocol/xe","kind":"pr","ref":"123","title":"fix(api): default CORS origin to wildcard, support origin lists, and align docs (#75)","url":"https://github.com/xeprotocol/xe/pull/123","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1565,"source":"github","source_ref":"6755090848","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0055.","created_at":"2026-11-10T00:15:36+00:00"}]}