next.config.ts 1.6 KB

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