next.config.mjs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * 生产用 Next 配置(纯 JS,运行时无需 TypeScript)
  3. * 与 next.config.ts 逻辑一致,供 Docker 生产镜像使用
  4. */
  5. const backendPort = process.env.NEXT_PUBLIC_BACKEND_PORT || "8080";
  6. const backendHost = process.env.NEXT_PUBLIC_BACKEND_HOST || "localhost";
  7. /** @type {import('next').NextConfig} */
  8. const nextConfig = {
  9. eslint: {
  10. ignoreDuringBuilds: true,
  11. },
  12. async rewrites() {
  13. if (process.env.NODE_ENV === "development") {
  14. return [
  15. {
  16. source: "/agent/profile/:path*",
  17. destination: `http://${backendHost}:${backendPort}/agent/profile/:path*`,
  18. },
  19. {
  20. source: "/agent/avatar/:path*",
  21. destination: `http://${backendHost}:${backendPort}/agent/avatar/:path*`,
  22. },
  23. {
  24. source: "/agent/embedding-config",
  25. destination: `http://${backendHost}:${backendPort}/agent/embedding-config`,
  26. },
  27. {
  28. source: "/agent/ai-config/:path*",
  29. destination: `http://${backendHost}:${backendPort}/agent/ai-config/:path*`,
  30. },
  31. {
  32. source: "/:path((?!_next|agent|chat|favicon.ico).*)",
  33. destination: `http://${backendHost}:${backendPort}/:path*`,
  34. },
  35. ];
  36. }
  37. return [];
  38. },
  39. images: {
  40. remotePatterns: [
  41. {
  42. protocol: "http",
  43. hostname: "192.168.124.9",
  44. port: backendPort,
  45. pathname: "/uploads/**",
  46. },
  47. {
  48. protocol: "http",
  49. hostname: "localhost",
  50. port: backendPort,
  51. pathname: "/uploads/**",
  52. },
  53. {
  54. protocol: "http",
  55. hostname: "127.0.0.1",
  56. port: backendPort,
  57. pathname: "/uploads/**",
  58. },
  59. ],
  60. },
  61. };
  62. export default nextConfig;