CoolFace
Apppublic

SpacesExamples/fastapi-nextjs-static

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
next.config.js32 linesDownload Raw Back to frontend
1/** @type {import('next').NextConfig} */2 3const API_HOST = process.env.API_HOST || '0.0.0.0'4const API_PORT = process.env.API_PORT || 78605 6console.log(`API_HOST: ${API_HOST}`)7console.log(`API_PORT: ${API_PORT}`)8console.log(`NODE_ENV: ${process.env.NODE_ENV}`)9 10const nextConfig = {11    output: 'export',12    // Optional: Change links `/me` -> `/me/` and emit `/me.html` -> `/me/index.html`13    // trailingSlash: true,14    // Optional: Prevent automatic `/me` -> `/me/`, instead preserve `href`15    // skipTrailingSlashRedirect: true,16    // Optional: Change the output directory `out` -> `dist`17    distDir: 'dist',18    async rewrites() {19        if (process.env.NODE_ENV !== 'production') {20            return [21                {22                    source: '/api/:path*',23                    destination: `http://${API_HOST}:${API_PORT}/:path*`,24                },25            ]26        }27        return []28    }29}30 31module.exports = nextConfig32