feat: add faucet API route at /api/faucet#121
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 806745d90f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/pages/_api/api/faucet.ts
Outdated
| ) | ||
| } | ||
|
|
||
| return fund(address.toLowerCase() as `0x${string}`, corsHeaders) |
There was a problem hiding this comment.
Remove state-changing behavior from the GET faucet route
The GET handler directly calls fund(...), which makes a non-idempotent blockchain action triggerable by any cross-site request mechanism that does not require CORS (for example link prefetchers, crawlers, or an embedded <img src>). In production this can spend faucet capacity without explicit user intent, so funding should be limited to POST (or otherwise protected against automatic GET traffic).
Useful? React with 👍 / 👎.
| 'Access-Control-Allow-Headers': 'Content-Type', | ||
| } | ||
|
|
||
| if (origin && allowedOrigins.some((allowed) => origin.startsWith(allowed))) |
There was a problem hiding this comment.
Match CORS origins exactly instead of using startsWith
The CORS check uses origin.startsWith(allowed), so an attacker-controlled origin like https://docs.tempo.xyz.attacker.com passes the whitelist and receives Access-Control-Allow-Origin. This weakens the intended browser-origin restriction for this endpoint; compare parsed origins/hosts with exact trusted values (or enforce proper subdomain boundary checks) rather than prefix matching.
Useful? React with 👍 / 👎.
Adds a faucet API endpoint at
docs.tempo.xyz/api/faucetso we can serve faucet requests directly from the docs site instead of requiring external curl commands.Returns
{ data: [{ hash }], error: null }on success.