next.config.mjs 791 B

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