next.config.mjs 900 B

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