React and FastAPI Application Integration
Connect a typed React frontend to a FastAPI service with a stable request and error contract, a local proxy and verified production routing.
Start with one route that reads and one that validates a small write, using synthetic records. Declare the method, path, request schema, public response schema and error meanings. Keep database objects, internal fields and secrets out of the response model. FastAPI can validate and filter serialized output through a declared response model. Check the generated OpenAPI document against what the client actually consumes. ## Key Points - [FastAPI response models](https://fastapi.tiangolo.com/tutorial/response-model/) - [FastAPI error handling](https://fastapi.tiangolo.com/tutorial/handling-errors/) - [FastAPI CORS](https://fastapi.tiangolo.com/tutorial/cors/) - [Vite dev server proxy](https://vite.dev/config/server-options.html#server-proxy)
skilldb get software-skills/react-fastapi-appFull skill: 30 linesReact and FastAPI Application Integration
Start with one route that reads and one that validates a small write, using synthetic records. Declare the method, path, request schema, public response schema and error meanings. Keep database objects, internal fields and secrets out of the response model. FastAPI can validate and filter serialized output through a declared response model. Check the generated OpenAPI document against what the client actually consumes.
Build one consistent request path
Generate TypeScript types from the agreed OpenAPI contract when the project uses generation, or maintain a small typed adapter and verify it with contract tests. Decode the actual response at a boundary where malformed data could mislead the UI. Define how request validation, unauthenticated, forbidden, absent and unavailable outcomes become visible states. Do not assume every rejected request uses the same body or that every response is JSON. Avoid sending server-only secrets into the frontend build.
Use a relative API path when the architecture allows a same-origin proxy. During development, Vite's server.proxy can forward that path, but production needs an equivalent reverse proxy or an intentionally configured API origin. If origins differ, allow the exact approved scheme, host and port with the necessary methods, headers and credentials. CORS affects browser access; the server still authenticates and authorizes every protected operation.
Test through both stacks
Run the app with test data and observe the browser's actual request paths, status codes and responses. Cover a successful read/write, a validation failure, a denied request, and a temporary server outage. For the cross-origin case test a preflight and the authenticated request from the approved origin. Verify deployment-like routing separately from the development proxy. Keep development docs and service ports outside public exposure unless explicitly required.
Check that old responses cannot replace the current UI on navigation and that a retry of a non-idempotent write cannot create duplicate effects. Record the generated schema revision, frontend/backend build, proxy or origin, and independently observed state. A direct curl success does not exercise browser preflight, credential policy or UI error rendering.
References and rights
Original SkillDB instructions under LicenseRef-SkillDB-Content. References were checked 2026-11-13 and used for technical verification.
Install this skill directly: skilldb add software-skills
Related Skills
Refactor
Systematically refactor code using safe transformation patterns — improving structure, readability, and maintainability without changing behavior. Use this skill when the user asks to refactor, restructure, clean up, simplify, decompose, or reorganize code. Also trigger for "this code is a mess," "make this more maintainable," "reduce complexity," "extract this into," "break this up," or any request to improve code structure while preserving existing functionality. Works with any language or framework.
Security Audit
Perform comprehensive security audits covering OWASP top 10 vulnerabilities, dependency CVEs, secrets exposure, and threat modeling. Use this skill when the user asks for a security review, vulnerability assessment, penetration test review, threat model, or security hardening guidance. Also trigger for "is this secure," "check for vulnerabilities," "security best practices," "audit this for security," or any concern about application security, data protection, or attack surface reduction. Works with any language, framework, or infrastructure.
SQL Best Practices
Generate secure, optimized SQL queries with proper parameterization, input validation, injection prevention, performance optimization, and cross-database syntax awareness for PostgreSQL, MySQL, SQLite, and SQL Server.
Test Gen
Auto-generate comprehensive test suites — unit tests, integration tests, and end-to-end tests — for any language or framework. Use this skill when the user asks to write tests, add test coverage, create a test suite, generate specs, or anything involving automated testing. Also trigger when the user says "add tests for this," "test this function," "increase coverage," "write specs," or mentions TDD, BDD, property-based testing, or test-driven development. Detects the project's language, test framework, and conventions automatically from the codebase.
Version Control Practices
Apply version control best practices for branching strategies, commit hygiene, collaboration workflows, and repository management. Use this skill when the user asks about git workflows, branching strategies, commit message conventions, merge vs rebase, monorepo management, or wants guidance on organizing their version control for solo or team development.
Adversarial Code Review
Adversarial implementation review methodology that validates code completeness against requirements with fresh objectivity. Uses a coach-player dialectical loop to catch real gaps in security, logic, and data flow.