next.config.ts51 lines · main
| 1 | import type { NextConfig } from 'next'; |
| 2 | |
| 3 | const config: NextConfig = { |
| 4 | reactStrictMode: true, |
| 5 | transpilePackages: [ |
| 6 | '@briven/ui', |
| 7 | '@briven/shared', |
| 8 | '@briven/config', |
| 9 | '@briven/auth', |
| 10 | ], |
| 11 | experimental: { |
| 12 | typedRoutes: true, |
| 13 | }, |
| 14 | async rewrites() { |
| 15 | // Read at request time, not module load, so env changes take effect |
| 16 | // without a rebuild. Default falls through to a local dev api. |
| 17 | // |
| 18 | // CRITICAL: use `fallback` (not a top-level array / afterFiles). |
| 19 | // Otherwise `/api/dashboard/auth-core/*` is rewritten to |
| 20 | // api.briven.tech/dashboard/... (404) and the App Router proxy never |
| 21 | // runs — Providers stuck on "loading methods…" / "load failed (404)". |
| 22 | // fallback = only when no local page/route matched, so local routes win: |
| 23 | // /api/dashboard/auth-core/* → apps/web proxy (cookies + Origin) |
| 24 | // /api/v1/* → api.briven.tech/v1/* |
| 25 | const apiOrigin = process.env.BRIVEN_API_ORIGIN ?? 'http://localhost:3001'; |
| 26 | return { |
| 27 | fallback: [ |
| 28 | { |
| 29 | source: '/api/:path*', |
| 30 | destination: `${apiOrigin}/:path*`, |
| 31 | }, |
| 32 | ], |
| 33 | }; |
| 34 | }, |
| 35 | async redirects() { |
| 36 | // Stable curl-install URL: `curl -fsSL https://briven.tech/install | sh` |
| 37 | // forwards to whichever install.sh is attached to the latest Codeberg |
| 38 | // release. Forgejo's /releases/latest/download/<asset> follows the |
| 39 | // newest non-draft release tag. |
| 40 | return [ |
| 41 | { |
| 42 | source: '/install', |
| 43 | destination: |
| 44 | 'https://codeberg.org/flndrn/briven/releases/latest/download/install.sh', |
| 45 | permanent: false, |
| 46 | }, |
| 47 | ]; |
| 48 | }, |
| 49 | }; |
| 50 | |
| 51 | export default config; |