Repository navigation
chore: add CSRF middleware for server functions - #9
Merged
Merged
Conversation
Silence the TanStack Start warning by protecting server-function RPC endpoints with the recommended CSRF middleware (same-origin check, scoped to serverFn requests), composed with the existing Sentry middleware. Low-risk here — the only server function is the read-only docs page loader with no auth or mutations — but the fix is trivial, follows the framework's recommendation, and covers any state-changing server function added later. Verified: build/lint pass, the warning is gone, and docs pages still load. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HhaZ2zL7bAqT3c8mRWTSs9
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
webview-bundle-website | 3a6add6 | Commit Preview URL Branch Preview URL |
Jul 01 2026, 03:39 PM |
There was a problem hiding this comment.
1 issue found across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Keep Sentry outermost so it observes the full request, including any CSRF rejection. Addresses cubic review on #9. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HhaZ2zL7bAqT3c8mRWTSs9
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.
Adds the recommended CSRF middleware to
src/start.tsto silence the TanStack Start warning:Is it actually needed?
For this site the risk is low — the only server function is the read-only docs page loader (no auth, no mutations, no user state), so a forged cross-site request could only fetch public docs. But the fix is one line, it's the framework's recommended default, and it protects any state-changing server function added later. So: worth doing to resolve the warning properly rather than suppressing it.
The middleware validates same-origin (Sec-Fetch-Site / Origin, with a Referer fallback) only for
serverFnrequests; legitimate same-origin calls pass unchanged.Verified
build+lintpass.🤖 Generated with Claude Code
https://claude.ai/code/session_01HhaZ2zL7bAqT3c8mRWTSs9
Summary by cubic
Add CSRF middleware for TanStack Start server functions to block cross-site calls and remove the framework warning. Uses
createCsrfMiddlewarefrom@tanstack/react-start, scoped toserverFnrequests and composed after the Sentry request middleware so Sentry sees any CSRF rejections.Written for commit 3a6add6. Summary will update on new commits.