ztjhz / BetterChatGPT

An amazing UI for OpenAI's ChatGPT (Website + Windows + MacOS + Linux)
http://bettergpt.chat/
Creative Commons Zero v1.0 Universal
8.03k stars 2.71k forks source link

centos8服务器部署时,无法启用公网ip,且运行5173端口未启动 #83

Closed misshy1990 closed 1 year ago

misshy1990 commented 1 year ago

npm run dev后显示如下:

VITE v4.1.4 ready in 233 ms

➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h to show help

flycran commented 1 year ago
ztjhz commented 1 year ago

你需要部署网站。你可以按照自述文件中的部署说明进行操作。

bahuzh commented 1 year ago

vite.config.ts 增加字段

export default defineConfig({ // ... server: { host: '0.0.0.0' } // ... });

lp123sun commented 1 year ago

vite.config.ts 增加字段

export default defineConfig({ // ... server: { host: '0.0.0.0' } // ... });

怎么用服务来启动呢

lp123sun commented 1 year ago

这么用nginx来反代呢?

ayaka14732 commented 1 year ago

@lp123sun 这不是基本的嘛,实在不会可以问 ChatGPT 😂

lp123sun commented 1 year ago

@lp123sun 这不是基本的嘛,实在不会可以问 ChatGPT 😂

我是对npm没一点概念的新手

bahuzh commented 1 year ago

这么用nginx来反代呢?

@lp123sun 那就不是这种方法了。 用,npm build 编译出来静态文件(dist目录),再用nginx反向代理。

lp123sun commented 1 year ago

这么用nginx来反代呢?

@lp123sun 那就不是这种方法了。 用,npm build 编译出来静态文件(dist目录),再用nginx反向代理。

谢谢提示,报错怎么处理呢:

npm build

Unknown command: "build"

Did you mean this? npm run build # run the "build" package script

To see a list of supported npm commands, run: npm help

npm run build

better-chatgpt@1.0.1 build tsc && vite build

src/utils/prompt.ts:4:18 - error TS2307: Cannot find module 'papaparse' or its corresponding type declarations.

4 import Papa from 'papaparse';


Found 1 error in src/utils/prompt.ts:4

npm notice 
npm notice New minor version of npm available! 9.5.1 -> 9.6.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.3
npm notice Run npm install -g npm@9.6.3 to update!
npm notice 
# npm install -g npm@9.6.3

removed 1 package, and changed 41 packages in 4s

18 packages are looking for funding
  run `npm fund` for details
# npm fund
better-chatgpt@1.0.1
├── https://github.com/sponsors/sindresorhus
│   └── electron-is-dev@2.0.0, is-plain-obj@4.1.0, escape-string-regexp@5.0.0, escape-string-regexp@4.0.0, import-fresh@3.3.0, parse-json@5.2.0, decompress-response@6.0.0, mimic-response@3.1.0, responselike@2.0.1, clone-response@1.0.3, get-stream@5.2.0, normalize-url@6.1.0, quick-lru@5.1.1, serialize-error@7.0.1, type-fest@0.13.1
├── https://locize.com
│   └── i18next@22.4.11
├─┬ https://opencollective.com/unified
│ │ └── react-markdown@8.0.5, hast-util-whitespace@2.0.1, remark-parse@10.0.1, mdast-util-from-markdown@1.3.0, mdast-util-to-string@3.1.1, unist-util-stringify-position@3.0.3, remark-rehype@10.1.0, mdast-util-to-hast@12.3.0, mdast-util-definitions@5.1.2, unist-util-generated@2.0.1, unist-util-position@4.0.4, unified@10.1.2, unist-util-visit@4.1.2, unist-util-is@5.2.1, unist-util-visit-parents@5.1.3, vfile@5.3.7, vfile-message@3.1.4, rehype-highlight@6.0.0, hast-util-to-text@3.1.2, hast-util-is-element@2.1.3, unist-util-find-after@4.0.1, rehype-katex@6.0.2, rehype-parse@8.0.4, hast-util-from-parse5@7.1.2, hastscript@7.2.0, hast-util-parse-selector@3.1.1, vfile-location@4.1.0, unist-util-remove-position@4.0.2, remark-gfm@3.0.1, mdast-util-gfm@2.0.2, mdast-util-gfm-autolink-literal@1.0.3, mdast-util-find-and-replace@2.2.2, mdast-util-gfm-footnote@1.0.2, mdast-util-gfm-strikethrough@1.0.3, mdast-util-gfm-table@1.0.7, mdast-util-gfm-task-list-item@1.0.2, mdast-util-to-markdown@1.5.0, mdast-util-phrasing@3.0.1, micromark-extension-gfm@2.0.1, micromark-extension-gfm-autolink-literal@1.0.3, micromark-extension-gfm-footnote@1.0.4, micromark-extension-gfm-strikethrough@1.0.4, micromark-extension-gfm-table@1.0.5, micromark-extension-gfm-tagfilter@1.0.1, micromark-extension-gfm-task-list-item@1.0.3, remark-math@5.1.1, mdast-util-math@2.0.2, micromark-extension-math@2.0.2
│ └── https://github.com/sponsors/wooorm
│     └── comma-separated-tokens@2.0.3, property-information@6.2.0, decode-named-character-reference@1.0.2, character-entities@2.0.2, trim-lines@3.0.1, space-separated-tokens@2.0.2, bail@2.0.2, trough@2.1.0, lowlight@2.8.1, fault@2.0.1, web-namespaces@2.0.1, ccount@2.0.1, markdown-table@3.0.3, longest-streak@3.1.0, zwitch@2.0.4
├─┬ https://opencollective.com/postcss/
│ │ └── autoprefixer@10.4.13, postcss@8.4.21, postcss-js@4.0.1, postcss-load-config@3.1.4, postcss-nested@6.0.0
│ ├── https://opencollective.com/browserslist
│ │   └── browserslist@4.21.5, update-browserslist-db@1.0.10, caniuse-lite@1.0.30001458
│ └── https://www.patreon.com/infusion
│     └── fraction.js@4.2.0
├─┬ https://github.com/open-cli-tools/concurrently?sponsor=1
│ │ └── concurrently@8.0.1
│ ├─┬ https://github.com/chalk/chalk?sponsor=1
│ │ │ └── chalk@4.1.2
│ │ └── https://github.com/chalk/ansi-styles?sponsor=1
│ │     └── ansi-styles@4.3.0
│ ├── https://opencollective.com/date-fns
│ │   └── date-fns@2.29.3
│ ├── https://github.com/sponsors/ljharb
│ │   └── shell-quote@1.8.0, resolve@1.22.1, is-core-module@2.11.0, supports-preserve-symlinks-flag@1.0.0, globalthis@1.0.3, define-properties@1.2.0, has-property-descriptors@1.0.0, get-intrinsic@1.2.0, has-symbols@1.0.3, minimist@1.2.8, defined@1.0.1
│ ├── https://github.com/chalk/supports-color?sponsor=1
│ │   └── supports-color@8.1.1
│ └── https://github.com/chalk/wrap-ansi?sponsor=1
│     └── wrap-ansi@7.0.0
├── https://opencollective.com/core-js
│   └── core-js@3.18.3, core-js-pure@3.29.0
├── https://opencollective.com/swc
│   └── @swc/core@1.3.42
├─┬ https://github.com/sindresorhus/got?sponsor=1
│ │ └── got@11.8.6
│ └── https://github.com/sindresorhus/is?sponsor=1
│     └── @sindresorhus/is@4.6.0
├─┬ https://opencollective.com/webpack
│ │ └── @develar/schema-utils@2.6.5
│ └── https://github.com/sponsors/epoberezkin
│     └── ajv@6.12.6
├── https://github.com/sponsors/gjtorikian/
│   └── isbinaryfile@4.0.10
├── https://github.com/sponsors/malept
│   └── @malept/cross-spawn-promise@1.1.1
├── https://github.com/sponsors/isaacs
│   └── glob@7.2.3, rimraf@3.0.2
├── https://github.com/sponsors/sibiraj-s
│   └── ci-info@3.8.0
├─┬ https://paulmillr.com/funding/
│ │ └── chokidar@3.5.3
│ └── https://github.com/sponsors/jonschlinkert
│     └── picomatch@2.3.1
└── https://github.com/sponsors/RubenVerborgh
    └── follow-redirects@1.15.2

# npm run build

> better-chatgpt@1.0.1 build
> tsc && vite build

src/utils/prompt.ts:4:18 - error TS2307: Cannot find module 'papaparse' or its corresponding type declarations.

4 import Papa from 'papaparse';

Found 1 error in src/utils/prompt.ts:4

ztjhz commented 1 year ago
  1. npm install
  2. npm run build
lp123sun commented 1 year ago
  1. npm install
  2. npm run build

npm install

npm WARN deprecated asar@3.2.0: Please use @electron/asar moving forward. There is no API change, just a package name change npm WARN deprecated electron-osx-sign@0.6.0: Please use @electron/osx-sign moving forward. Be aware the API is slightly different npm WARN deprecated core-js@3.18.3: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

added 561 packages, and audited 562 packages in 1m

148 packages are looking for funding run npm fund for details

6 high severity vulnerabilities

To address all issues (including breaking changes), run: npm audit fix --force

Run npm audit for details.

npm audit fix --force

npm WARN using --force Recommended protections disabled. npm WARN audit Updating electron-builder to 24.1.2, which is a SemVer major change. npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs

added 110 packages, removed 18 packages, changed 15 packages, and audited 654 packages in 8s

162 packages are looking for funding run npm fund for details

found 0 vulnerabilities

npm install

up to date, audited 654 packages in 2s

162 packages are looking for funding run npm fund for details

found 0 vulnerabilities

npm run build

better-chatgpt@1.0.2 build tsc && vite build

vite v4.1.4 building for production... ✓ 1455 modules transformed. dist/index.html 1.32 kB dist/assets/tiktoken_bg-cfed79ec.wasm 798.64 kB dist/assets/index-c056e3d1.css 41.14 kB │ gzip: 7.83 kB dist/assets/cl100k_base-6bc6573e.js 1,090.83 kB │ gzip: 505.54 kB dist/assets/index-5b0dca8d.js 1,525.17 kB │ gzip: 446.27 kB

(!) Some chunks are larger than 500 kBs after minification. Consider:

可以使用了,谢谢,怎么在页面设置一个账号密码呢,输入正确后,再打开页面。

ayaka14732 commented 1 year ago

您可以使用 Nginx 的 HTTP Basic Authentication 来在页面中设置账号密码认证。

下面是一个简单的示例配置文件:

server {
    ...

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/.htpasswd;

   ...
}

这个配置文件假定您已经有一个基本的 Nginx 配置。

auth_basic 指令设置了用于认证的提示消息,例如 "Restricted Access"。auth_basic_user_file 指令设置了一个包含账户和密码的文件的路径,这个文件可以使用 htpasswd 工具生成,例如:

sudo htpasswd -c /etc/nginx/.htpasswd username

这将要求您输入密码并将其存储在 /etc/nginx/.htpasswd 文件中,该文件的权限应该设置为只读,仅限于 Nginx 用户。

完成上述设置后,您应该能够在浏览器中打开您的网站,并在访问主页时看到一个基本身份验证对话框。输入正确的用户名和密码后,Nginx 将允许您访问网站的内容。

lp123sun commented 1 year ago

按这个方法设置后,可以了,非常感谢

lp123sun commented 1 year ago

npm run dev后显示如下:

VITE v4.1.4 ready in 233 ms

➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h to show help

以为在服务器运行的,发现是下载代码,在本地电脑运行的,还要挂代理啊,怎么改成在服务器运行?

lp123sun commented 1 year ago

你需要部署网站。你可以按照自述文件中的部署说明进行操作。

以为在服务器运行的,发现是下载代码,在本地电脑运行的,要挂代理啊,怎么改成在服务器运行呢?

ayaka14732 commented 1 year ago

可以查看 README,有很多部署方法

lp123sun commented 1 year ago

可以查看 README,有很多部署方法

怎么样设置,可以是在服务器运行呢。现在是在访问页面的电脑浏览器上面运行的。