WongSaang / chatgpt-ui

A ChatGPT web client that supports multiple users, multiple languages, and multiple database connections for persistent data storage. Provides Docker images and quick deployment scripts.
https://wongsaang.github.io/chatgpt-ui/
MIT License
1.51k stars 332 forks source link

node .output/server/index.mjs #267

Open JuJoker opened 5 months ago

JuJoker commented 5 months ago

I don't have any knowledge about nuxt. When running the project, the following problems occurred:

I executed the 'yarn install' command to download the related dependencies, and then executed 'yarn build' command to package it. After the packaging was completed, executing 'node .output/server/index.mjs' resulted in an error (Node version 16.16, Windows 11 machine), the error message is as follows: 微信图片_20240411165839

Performing the above operations on Ubuntu 22.04 does not result in an error. After executing 'node .output/server/index.mjs', it displays 'listening ::3000', but there is no response when accessing it in the browser; it keeps loading.

Can I start the packaged project directly using 'node .output/server/index.mjs' without deploying it using Docker?

我对nuxt没有了解,在运行项目时出现了下面的问题

  1. 我执行yarn install命令下载相关依赖,然后执行yarn build命令进行打包,打包完毕后,执行 ··· node .output/server/index.mjs ··· 报错(node版本16.16, 机器windows11),报错如下:

微信图片_20240411165839

  1. 在Ubuntu22.04上进行上述操作,不会报错,执行完毕node .output/server/index.mjs之后,listening ::3000,但是在浏览器中访问没有反应,一直在加载

请问如果不使用docker部署,直接使用node .output/server/index.mjs启动打包的项目可以吗?

WongSaang commented 5 months ago

https://wongsaang.github.io/chatgpt-ui/guide/configuration.html#client-configuration

This issue is likely caused by missing environment variables. Please create a .env file in the project root directory, and then add the environment variables as mentioned in the documentation. Especially SERVER_DOMAIN, which specifies the address of your backend for the proxy to connect to.

JuJoker commented 5 months ago

https://wongsaang.github.io/chatgpt-ui/guide/configuration.html#client-configuration

This issue is likely caused by missing environment variables. Please create a .env file in the project root directory, and then add the environment variables as mentioned in the documentation. Especially SERVER_DOMAIN, which specifies the address of your backend for the proxy to connect to.

Thank you, the .env file had been placed and the SERVER_DOMAIN were also set. If I run the yarn dev , the project can run successfully, but when i run the above node .output/server/index.mjs after bash yarn build. At the same time, when i deploy the project on the Ubuntu22.04, the .env file is not work as you mentioned. I alter the content as follows annotation to solve this problem

import { createProxyMiddleware } from 'http-proxy-middleware'
export default defineEventHandler(async (event) => {
    await new Promise((resolve, reject) => {
        createProxyMiddleware({
            target: process.env.SERVER_DOMAIN,
            // target: "http://xxx.xxxx.xxx.1xx:8000/",
            pathFilter: '/api',
        })(event.node.req, event.node.res, (err) => {
            if (err)
                reject(err)
            else
                resolve(true)
        })
    })
})
WongSaang commented 5 months ago

You can also define system-level environment variables so that Node can read them. Alternatively, you can prefix your command with an environment variable, for example: MY_ENV_VAR=example_value node your_script.js

JuJoker commented 5 months ago

You can also define system-level environment variables so that Node can read them. Alternatively, you can prefix your command with an environment variable, for example: MY_ENV_VAR=example_value node your_script.js

Thank you, the issue was solved by define the systemctl-level environment as SERVER_DOMAIN = ipaddress:port, but the nuxt project seems cannot access the backend server , and my SERVER_DOMAIN is set 127.0.0.1:8000. I tried to run the django project with the command python manage.py runserver 0.0.0.0:8000 also fails, and the settings is python ALLOWED_HOSTS=['*'] In the end, does the coffee can be pay with Alipay. Thank you very much.

WongSaang commented 5 months ago

You can also define system-level environment variables so that Node can read them. Alternatively, you can prefix your command with an environment variable, for example: MY_ENV_VAR=example_value node your_script.js

Thank you, the issue was solved by define the systemctl-level environment as SERVER_DOMAIN = ipaddress:port, but the nuxt project seems cannot access the backend server , and my SERVER_DOMAIN is set 127.0.0.1:8000. I tried to run the django project with the command python manage.py runserver 0.0.0.0:8000 also fails, and the settings is python ALLOWED_HOSTS=['*'] In the end, does the coffee can be pay with Alipay. Thank you very much.

BMC doesn't seem to support Alipay, but you can input UnionPay card information in the bank card section. If you'd like to support me, you can give it a try. Thank you!