File tree Expand file tree Collapse file tree 5 files changed +26
-12
lines changed
Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ export async function createServer(formData: FormData) {
254254### ❌ NEVER DO
255255
256256- ** Use ` any ` type** - STRICTLY FORBIDDEN. Use ` unknown ` + type guards or proper types
257- - Edit files in ` src/generated/* ` (auto- generated)
257+ - ** Edit files in ` src/generated/* ` ** - Auto- generated, will be overwritten on regeneration
258258- Use ` 'use client' ` on every component
259259- Create manual fetch logic in components
260260- Use ` .then() ` promise chains
@@ -274,6 +274,8 @@ export async function createServer(formData: FormData) {
274274
275275### Using Generated API Client
276276
277+ ** ⚠️ IMPORTANT: Never edit files in ` src/generated/* ` ** - they are auto-generated and will be overwritten.
278+
277279** Queries (GET)** :
278280
279281``` typescript
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ This document provides context and guidelines for Claude (and other AI assistant
6868### 3. Generated API Client
6969
7070- ** Never write manual fetch logic** - Always use hey-api generated hooks
71+ - ** Never edit generated files** - They are regenerated from OpenAPI spec and changes will be lost
7172- API client regenerated from OpenAPI spec via custom script
7273- Type-safe API calls with automatic loading/error states
7374
@@ -137,7 +138,9 @@ pnpm generate-client:nofetch # Regenerate without fetching
137138### DON'T ❌
138139
1391401 . ** 🚫 Don't EVER use ` any ` type** - STRICTLY FORBIDDEN. Use ` unknown ` + type guards or proper types
140- 2 . ** Don't edit generated files** - ` src/generated/* ` is auto-generated
141+ 2 . ** 🚫 Don't EVER edit generated files** - ` src/generated/* ` is auto-generated and will be overwritten
142+ - Generated files are overwritten on every ` pnpm generate-client ` run
143+ - If you need to configure or extend the client, do it in your own files
1411443 . ** Don't use ` 'use client' ` everywhere** - Only when necessary
1421454 . ** Don't create custom fetch logic** - Use hey-api hooks
1431465 . ** Don't use ` .then() ` ** - Use async/await
Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import { Geist , Geist_Mono } from "next/font/google" ;
33import { Toaster } from "sonner" ;
4+ import "@/lib/api-client" ;
45import "./globals.css" ;
56
67const geistSans = Geist ( {
Original file line number Diff line number Diff line change @@ -20,13 +20,4 @@ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
2020 override ?: Config < ClientOptions & T > ,
2121) => Config < Required < ClientOptions > & T > ;
2222
23- // Configure client with baseUrl for both SSR and client-side
24- // In development: points to standalone MSW mock server (http://localhost:9090)
25- // In production: points to real backend API
26- const baseUrl = process . env . NEXT_PUBLIC_API_BASE_URL || "http://localhost:9090" ;
27-
28- export const client = createClient (
29- createConfig < ClientOptions2 > ( {
30- baseUrl,
31- } ) ,
32- ) ;
23+ export const client = createClient ( createConfig < ClientOptions2 > ( ) ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * API Client Configuration
3+ *
4+ * Configures the hey-api generated client with the correct base URL.
5+ * This must be imported before any API calls are made.
6+ */
7+
8+ import { client } from "@/generated/client.gen" ;
9+
10+ // Configure client with baseUrl for both SSR and client-side
11+ // In development: points to standalone MSW mock server (http://localhost:9090)
12+ // In production: points to real backend API
13+ client . setConfig ( {
14+ baseUrl : process . env . NEXT_PUBLIC_API_BASE_URL || "http://localhost:9090" ,
15+ } ) ;
16+
17+ export { client } ;
You can’t perform that action at this time.
0 commit comments