next.config.mjs 832 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. source: "/google-fonts/:path*",
  14. destination: "https://fonts.googleapis.com/:path*",
  15. },
  16. ];
  17. const apiUrl = process.env.API_URL;
  18. if (apiUrl) {
  19. console.log("[Next] using api url ", apiUrl);
  20. ret.push({
  21. source: "/api/:path*",
  22. destination: `${apiUrl}/:path*`,
  23. });
  24. }
  25. return {
  26. beforeFiles: ret,
  27. };
  28. },
  29. webpack(config) {
  30. config.module.rules.push({
  31. test: /\.svg$/,
  32. use: ["@svgr/webpack"],
  33. });
  34. return config;
  35. },
  36. output: "standalone",
  37. };
  38. export default nextConfig;