next.config.mjs 715 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /** @type {import('next').NextConfig} */
  2. const nextConfig = {
  3. experimental: {
  4. appDir: true,
  5. },
  6. async rewrites() {
  7. const ret = [
  8. {
  9. source: "/api/proxy/:path*",
  10. destination: "https://api.openai.com/:path*",
  11. },
  12. ];
  13. const apiUrl = process.env.API_URL;
  14. if (apiUrl) {
  15. console.log("[Next] using api url ", apiUrl);
  16. ret.push({
  17. source: "/api/:path*",
  18. destination: `${apiUrl}/:path*`,
  19. });
  20. }
  21. return {
  22. beforeFiles: ret,
  23. };
  24. },
  25. webpack(config) {
  26. config.module.rules.push({
  27. test: /\.svg$/,
  28. use: ["@svgr/webpack"],
  29. });
  30. return config;
  31. },
  32. output: "standalone",
  33. };
  34. export default nextConfig;