ChatGPTNextWeb / ChatGPT-Next-Web

A cross-platform ChatGPT/Gemini UI (Web / PWA / Linux / Win / MacOS). 一键拥有你自己的跨平台 ChatGPT/Gemini 应用。
https://app.nextchat.dev/
MIT License
75.43k stars 58.87k forks source link

[Feature Request]: server.js 如何打开 HTTPS #4726

Closed Testst188 closed 3 months ago

Testst188 commented 4 months ago

Problem Description

新版Docker下的js如何修改打开HTTPS

const path = require('path')

const dir = path.join(__dirname)

process.env.NODE_ENV = 'production'
process.chdir(__dirname)

const currentPort = parseInt(process.env.PORT, 10) || 3000
const hostname = process.env.HOSTNAME || '0.0.0.0'

let keepAliveTimeout = parseInt(process.env.KEEP_ALIVE_TIMEOUT, 10)
const nextConfig = {"env":{},"eslint":{"ignoreDuringBuilds":false},"typescript":{"ignoreBuildErrors":false,"tsconfigPath":"tsconfig.json"},"distDir":

process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(nextConfig)

require('next')
const { startServer } = require('next/dist/server/lib/start-server')

if (
  Number.isNaN(keepAliveTimeout) ||
  !Number.isFinite(keepAliveTimeout) ||
  keepAliveTimeout < 0
) {
  keepAliveTimeout = undefined
}

startServer({
  dir,
  isDev: false,
  config: nextConfig,
  hostname,
  port: currentPort,
  allowRetry: false,
  keepAliveTimeout,
}).catch((err) => {
  console.error(err);
  process.exit(1);
});

Solution Description

syncmeta旧版server.js的修改正常使用HTTPS

const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
};

然后修改这一行: 原来是这样:const server = http.createServer(async (req, res) => { 修改成:const server = https.createServer(options, async (req, res) => { 新版本的JS修改无效,请问如何解决

Alternatives Considered

No response

Additional Context

No response

Dean-YZG commented 4 months ago

我觉得,您可以保留原来的https服务,作为一个网关负责流量转发

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


I think you can keep the original https service and use it as a gateway responsible for traffic forwarding

Testst188 commented 3 months ago

我觉得,您可以保留原来的https服务,作为一个网关负责流量转发

好的谢谢

Issues-translate-bot commented 3 months ago

Bot detected the issue body's language is not English, translate it automatically.


I think you can keep the original https service and use it as a gateway responsible for traffic forwarding

OK, thanks