From ca64eecffb0e8b4b2ad405416accb364e3c2c76f Mon Sep 17 00:00:00 2001 From: mikicv Date: Wed, 8 Oct 2025 23:31:09 +0100 Subject: [PATCH] remove wrong props --- Dockerfile.production | 4 +++- next.config.js | 4 ---- server.js | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 server.js diff --git a/Dockerfile.production b/Dockerfile.production index 6738f58..1179702 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -42,12 +42,14 @@ WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 -ENV TRUST_PROXY=1 # Copy necessary files from builder stage COPY --from=builder /app/.next/standalone ./ COPY --from=builder --chown=root:root /app/.next/static ./.next/static +# Copy custom server.js that handles proxy headers +COPY --from=builder /app/server.js ./server.js + # Copy compiled database scripts instead of TypeScript sources COPY --from=builder /app/dist ./dist diff --git a/next.config.js b/next.config.js index e115e1b..f32741d 100644 --- a/next.config.js +++ b/next.config.js @@ -12,10 +12,6 @@ const nextConfig = { output: process.env.NODE_ENV === 'production' ? 'standalone' : undefined, // External packages for better SQLite3 compatibility (Next.js 15+ syntax) serverExternalPackages: ['better-sqlite3'], - // Trust proxy headers for Cloudflare tunnel - experimental: { - trustHost: true, - }, }; module.exports = nextConfig; diff --git a/server.js b/server.js new file mode 100644 index 0000000..069c625 --- /dev/null +++ b/server.js @@ -0,0 +1,26 @@ +const { createServer } = require('http'); +const { parse } = require('url'); +const next = require('next'); + +const dev = process.env.NODE_ENV !== 'production'; +const hostname = process.env.HOSTNAME || 'localhost'; +const port = parseInt(process.env.PORT || '3000', 10); + +const app = next({ dev, hostname, port }); +const handle = app.getRequestHandler(); + +app.prepare().then(() => { + createServer((req, res) => { + // Trust proxy headers from Cloudflare tunnel + const proto = req.headers['x-forwarded-proto']; + if (proto === 'https') { + req.connection.encrypted = true; + } + + const parsedUrl = parse(req.url, true); + handle(req, res, parsedUrl); + }).listen(port, hostname, (err) => { + if (err) throw err; + console.log(`> Ready on http://${hostname}:${port}`); + }); +});