diff --git a/Dockerfile b/Dockerfile index 1b698f579d2..ae9a17cddbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,8 +18,6 @@ RUN apk update && apk add --no-cache git ENV OPENAI_API_KEY="" ENV GOOGLE_API_KEY="" ENV CODE="" -ENV HOSTNAME="0.0.0.0" -ENV PORT="3000" WORKDIR /app COPY --from=deps /app/node_modules ./node_modules @@ -36,8 +34,6 @@ ENV PROXY_URL="" ENV OPENAI_API_KEY="" ENV GOOGLE_API_KEY="" ENV CODE="" -ENV HOSTNAME="0.0.0.0" -ENV PORT="3000" COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ @@ -47,6 +43,7 @@ COPY --from=builder /app/.next/server ./.next/server EXPOSE 3000 CMD if [ -n "$PROXY_URL" ]; then \ + export HOSTNAME="0.0.0.0"; \ protocol=$(echo $PROXY_URL | cut -d: -f1); \ host=$(echo $PROXY_URL | cut -d/ -f3 | cut -d: -f1); \ port=$(echo $PROXY_URL | cut -d: -f3); \ diff --git a/server.ts b/server.ts index 68d0eb38c86..72620537e76 100644 --- a/server.ts +++ b/server.ts @@ -4,8 +4,8 @@ import next from 'next'; import { setupWebSocket } from './app/api/websocket'; const dev = process.env.NODE_ENV !== 'production'; -const hostname = process.env.HOSTNAME || '0.0.0.0'; -const port = parseInt(process.env.PORT || '3000', 10); +const hostname = 'localhost'; +const port = 3000; const app = next({ dev, hostname, port }); const handle = app.getRequestHandler(); @@ -13,25 +13,6 @@ const handle = app.getRequestHandler(); app.prepare().then(() => { const server = createServer(async (req, res) => { try { - if (req.method === 'OPTIONS') { - res.writeHead(200, { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type, Authorization', - 'Access-Control-Max-Age': '86400' - }); - res.end(); - return; - } - - if (req.headers.upgrade && req.headers.upgrade.toLowerCase() === 'websocket') { - res.writeHead(101, { - 'Upgrade': 'websocket', - 'Connection': 'Upgrade' - }); - return; - } - const parsedUrl = parse(req.url!, true); await handle(req, res, parsedUrl); } catch (err) { @@ -43,8 +24,7 @@ app.prepare().then(() => { setupWebSocket(server); - server.listen(port, hostname, () => { - console.log(`> Server listening at http://${hostname}:${port}`); - console.log(`> WebSocket server is ready`); + server.listen(port, () => { + console.log(`> Ready on http://${hostname}:${port}`); }); }); \ No newline at end of file