fix: resolve frontend/backend integration bugs

- Rename skincare route prefix /skin-snapshots → /skincare to match API client
- Add redirect_slashes=False to FastAPI app; change collection routes from "/" to ""
  to eliminate 307 redirects on POST/GET without trailing slash
- Fix redirect() inside try/catch in products/new and routines/new server actions
  (SvelteKit redirect() throws and was being caught as a 500 error)
- Eagerly load inventory and steps relationships via explicit SELECT + model_dump(mode="json"),
  working around SQLModel 0.0.37 not serializing Relationship fields in response_model
- Add field_validator for product_effect_profile to coerce DB-returned dict → ProductEffectProfile,
  eliminating Pydantic serializer warning
- Update all tests to use routes without trailing slash

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Piotr Oleszczyk 2026-02-26 21:53:17 +01:00
parent 8d4f9d1fc6
commit 9bf94a979c
11 changed files with 85 additions and 68 deletions

View file

@ -17,7 +17,7 @@ async def lifespan(app: FastAPI):
yield
app = FastAPI(title="innercontext API", lifespan=lifespan)
app = FastAPI(title="innercontext API", lifespan=lifespan, redirect_slashes=False)
app.add_middleware(
CORSMiddleware,
@ -30,7 +30,7 @@ app.include_router(products.router, prefix="/products", tags=["products"])
app.include_router(inventory.router, prefix="/inventory", tags=["inventory"])
app.include_router(health.router, prefix="/health", tags=["health"])
app.include_router(routines.router, prefix="/routines", tags=["routines"])
app.include_router(skincare.router, prefix="/skin-snapshots", tags=["skincare"])
app.include_router(skincare.router, prefix="/skincare", tags=["skincare"])
@app.get("/health-check")