2025-09-09 14:37:32 +05:30
|
|
|
import { defineConfig } from '@hey-api/openapi-ts';
|
2026-07-03 18:14:03 +05:30
|
|
|
import { loadEnvConfig } from '@next/env';
|
|
|
|
|
|
|
|
|
|
// Load .env.local / .env the same way Next.js does, so client generation targets
|
|
|
|
|
// the backend THIS worktree actually runs on (per-worktree BACKEND_URL set by
|
|
|
|
|
// scripts/worktree-assign-port.sh). Falls back to the default dev port if unset.
|
|
|
|
|
loadEnvConfig(process.cwd());
|
|
|
|
|
|
|
|
|
|
const backendUrl = (
|
|
|
|
|
process.env.BACKEND_URL ||
|
|
|
|
|
process.env.NEXT_PUBLIC_BACKEND_URL ||
|
|
|
|
|
'http://127.0.0.1:8000'
|
|
|
|
|
).replace(/\/+$/, '');
|
2025-09-09 14:37:32 +05:30
|
|
|
|
|
|
|
|
export default defineConfig({
|
2026-07-03 18:14:03 +05:30
|
|
|
input: `${backendUrl}/api/v1/openapi.json`,
|
2025-09-09 14:37:32 +05:30
|
|
|
output: 'src/client',
|
|
|
|
|
plugins: [{
|
|
|
|
|
name: '@hey-api/client-fetch',
|
2026-07-03 18:14:03 +05:30
|
|
|
runtimeConfigPath: './src/lib/apiClient',
|
2025-09-09 14:37:32 +05:30
|
|
|
}],
|
|
|
|
|
});
|