anse-app / chatgpt-demo

Minimal web UI for ChatGPT.
https://chatgpt.ddiu.me
MIT License
8k stars 3.82k forks source link

No response on vercel deployment with custom domains. #302

Open zydou opened 1 year ago

zydou commented 1 year ago

Describe the bug

I followed the "Deploy With Vercel" instructions and deployed successfully with env_var OPENAI_API_KEY and SITE_PASSWORD. The urls generated by vercel works fine but the site with my custom domain faild. (The website and the chatbox can show properly but has no response of any input)

I use F12 to show the network activities and found that this request was canceled by the browser. (Tested on Chrome, Safari, Firefox)

https://my-custom-domain.com/_astro/hoisted.397d79e3.js

But I can open this url directly in the same browser.

Reproduction

Click the "Deploy With Vercel" icon and add a custom domain.

System Info

Verce with default settings

Used Package Manager

n/a

Validations

zydou commented 1 year ago

network activities of my custom domain:

image image

network activities of xxx.vercel.app:

image image
marcyquan commented 1 year ago

我也是部署到Vercel错误,但是我是无法部署。 Deploy Preparing Git Repository. An unexpected error occurred. Our team has already been notified and are working to resolve the issue, please try again shortly.

zydou commented 1 year ago

@marcyquan Hi, you can try these steps:

  1. Fork this repo to your GitHub account
  2. Go to vercel and link your GitHub account to vercel
  3. On vercel, add a new project and choose chatgpt-demo to import. image
yzh990918 commented 1 year ago

@zydou Sorry, based on your description, I still can't see the problem, But you can checkout this following steps:

  1. User cancellation: If a user manually refreshes the page or closes the browser tab while a request is in progress, this will cause the browser to cancel the unfinished request.
  2. Network failure: If there is a problem with the network connection, such as the server not responding, DNS errors, or timeouts, the browser will cancel the request.
  3. Resource limitation: Some browsers limit the number of requests that can be sent simultaneously, and if too many requests are made, the browser may cancel some of the requests to reduce the load.
  4. Security policy: If a request violates the browser's security policy, such as a cross-domain request not properly set up with CORS headers, the browser will cancel the request.
miguelgargallo commented 1 year ago

Ams I run this on chat.pylar.org, and all seems to work perfectly

zydou commented 1 year ago

@yzh990918 Hi, after a thorough examination, I can confidently confirm that the following factors are not responsible for the issue.

  1. I waited for enough time and noticed that all requests to https://my-custom-domain.com/*** were successful except for one: https://my-custom-domain.com/_astro/hoisted.397d79e3.js. This suggests that there is no issue with my network connection to the domain my-custom-domain.com. However, this particular request was immediately cancelled by the browser and it does not appear to be related to any user cancellation or network failure.

  2. I tested multiple browsers on multiple platforms and got the same issue across all of them.

    • latest version of Safari on iPhone, Mac-mini, Macbook Air(M2)
    • latest version of Chrome on Mac-mini, Macbook Air(M2), Win11
    • latest version of Firefox on iPhone, Win11

So I don't think this is related to resource limitation

Regarding the Security policy you mentioned, I have limited knowledge about it and am unsure how to modify or evaluate it. However, my website is currently protected by Cloudflare CDN. Is there any correlation between them?

BTW: These are my sites deployed on vercel:

You can access these websites and monitor network activity without a password. (you can provide your email address and I'll send you the passwd for further investigation)

ddiu8081 commented 1 year ago

I notices that in network activities, the failed request was initiated by rocket-loader.min.js.

ScreenShot 2023-03-22 at 17 57 24@2x

But in my own deployed instance, the request is initiated directly by (index).

ScreenShot 2023-03-22 at 18 04 10@2x

Could this be the cause of the problem? Rocket Loader is an acceleration service launched by Cloudflare. Does it mean that you have enabled the relevant service in Cloudflare? You can try to temporarily close the service and retry to see if the problem still occurs.

Reference:

zydou commented 1 year ago

@ddiu8081 Yes, I do have Rocket Loader enabled on Cloudflare. I disabled this optimization according to the url you mentioned above and clear the cache both on the CDN side and my browser side. Then I revisited the https://chatgpt-api.zydou.me and https://chatgpt-api.zydou.me/_astro/hoisted.397d79e3.js got passed now. But the problem still exists :(

The website and chatbox display correctly, and I am able to enter text into the chatbox. However, when I hit ENTER, the text does not send to the remote as expected. Instead, it creates a new line within the chatbox.

screenshot before I hit ENTER:

image

screenshot after I hit ENTER:

image

I observed two differences:

  1. A new line was added (blue box)
  2. A small rectangle appeared (red box)

Any ideas about that? Would you mind providing your email address so that I can send you the site password?

zydou commented 1 year ago

More details:

The deployment is based on the latest commit https://github.com/ddiu8081/chatgpt-demo/commit/bdd34e1481c0c70b9ef0aebb45df9be477954394

The build log:

[19:26:59.103] Running build in San Francisco, USA (West) – sfo1
[19:26:59.153] Cloning github.com/zydou/chatgpt-demo (Branch: main, Commit: bdd34e1)
[19:26:59.163] Skipping build cache, deployment was triggered without cache.
[19:27:00.086] Cloning completed: 931.869ms
[19:27:00.345] Running "vercel build"
[19:27:00.919] Vercel CLI 28.17.0
[19:27:01.705] Detected `pnpm-lock.yaml` generated by pnpm 7...
[19:27:01.719] Installing dependencies...
[19:27:02.493] Lockfile is up to date, resolution step is skipped
[19:27:02.577] Progress: resolved 1, reused 0, downloaded 0, added 0
[19:27:02.830] Packages: +798
[19:27:02.830] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[19:27:03.538] Packages are hard linked from the content-addressable store to the virtual store.
[19:27:03.538]   Content-addressable store is at: /vercel/.local/share/pnpm/store/v3
[19:27:03.538]   Virtual store is at:             node_modules/.pnpm
[19:27:03.585] Progress: resolved 798, reused 0, downloaded 7, added 1
[19:27:04.585] Progress: resolved 798, reused 0, downloaded 48, added 40
[19:27:05.595] Progress: resolved 798, reused 0, downloaded 113, added 107
[19:27:06.598] Progress: resolved 798, reused 0, downloaded 182, added 182
[19:27:07.603] Progress: resolved 798, reused 0, downloaded 253, added 248
[19:27:08.608] Progress: resolved 798, reused 0, downloaded 353, added 348
[19:27:09.611] Progress: resolved 798, reused 0, downloaded 440, added 436
[19:27:10.618] Progress: resolved 798, reused 0, downloaded 506, added 504
[19:27:11.621] Progress: resolved 798, reused 0, downloaded 545, added 539
[19:27:12.621] Progress: resolved 798, reused 0, downloaded 598, added 593
[19:27:13.629] Progress: resolved 798, reused 0, downloaded 635, added 631
[19:27:14.633] Progress: resolved 798, reused 0, downloaded 688, added 685
[19:27:15.634] Progress: resolved 798, reused 0, downloaded 763, added 756
[19:27:16.634] Progress: resolved 798, reused 0, downloaded 797, added 797
[19:27:17.634] Progress: resolved 798, reused 0, downloaded 798, added 798, done
[19:27:17.741] .../esbuild@0.15.18/node_modules/esbuild postinstall$ node install.js
[19:27:17.742] .../esbuild@0.16.17/node_modules/esbuild postinstall$ node install.js
[19:27:17.840] .../esbuild@0.15.18/node_modules/esbuild postinstall: Done
[19:27:17.848] .../esbuild@0.16.17/node_modules/esbuild postinstall: Done
[19:27:18.468] 
[19:27:18.468] dependencies:
[19:27:18.469] + @astrojs/netlify 2.0.0
[19:27:18.469] + @astrojs/node 5.1.0
[19:27:18.469] + @astrojs/solid-js 2.1.0
[19:27:18.469] + @astrojs/vercel 3.2.1
[19:27:18.469] + @unocss/reset 0.50.4
[19:27:18.469] + astro 2.1.3
[19:27:18.469] + eslint 8.36.0
[19:27:18.469] + eventsource-parser 0.1.0
[19:27:18.469] + highlight.js 11.7.0
[19:27:18.469] + js-sha256 0.9.0
[19:27:18.470] + katex 0.6.0
[19:27:18.470] + markdown-it 13.0.1
[19:27:18.470] + markdown-it-highlightjs 4.0.1
[19:27:18.470] + markdown-it-katex 2.0.3
[19:27:18.470] + solid-js 1.6.12
[19:27:18.470] + solidjs-use 1.2.0
[19:27:18.470] + undici 5.21.0
[19:27:18.470] 
[19:27:18.470] devDependencies:
[19:27:18.470] + @evan-yang/eslint-config 1.0.1
[19:27:18.470] + @iconify-json/carbon 1.1.16
[19:27:18.471] + @types/markdown-it 12.2.3
[19:27:18.471] + @typescript-eslint/parser 5.55.0
[19:27:18.471] + @unocss/preset-attributify 0.50.4
[19:27:18.471] + @unocss/preset-icons 0.50.4
[19:27:18.471] + @unocss/preset-typography 0.50.4
[19:27:18.471] + eslint-plugin-astro 0.24.0
[19:27:18.471] + punycode 2.3.0
[19:27:18.471] + unocss 0.50.4
[19:27:18.472] 
[19:27:18.472] Done in 16.6s
[19:27:21.211] 11:27:21 AM [content] No content directory found. Skipping type generation.
[19:27:21.295] 11:27:21 AM [build] output target: server
[19:27:21.296] 11:27:21 AM [build] deploy adapter: @astrojs/vercel/edge
[19:27:21.296] 11:27:21 AM [build] Collecting build info...
[19:27:21.297] 11:27:21 AM [build] Completed in 651ms.
[19:27:21.298] 11:27:21 AM [build] Building server entrypoints...
[19:27:25.132] 11:27:25 AM [build] Completed in 3.83s.
[19:27:25.132] 
[19:27:25.132]  building client 
[19:27:30.057] Use of eval in "node_modules/.pnpm/js-sha256@0.9.0/node_modules/js-sha256/src/sha256.js" is strongly discouraged as it poses security risks and may cause issues with minification.
[19:27:30.057] Use of eval in "node_modules/.pnpm/js-sha256@0.9.0/node_modules/js-sha256/src/sha256.js" is strongly discouraged as it poses security risks and may cause issues with minification.
[19:27:32.170] 
[19:27:32.171] (!) Some chunks are larger than 500 kBs after minification. Consider:
[19:27:32.171] - Using dynamic import() to code-split the application
[19:27:32.171] - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
[19:27:32.171] - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
[19:27:32.172] Completed in 7.04s.
[19:27:32.172] 
[19:27:32.180] 
[19:27:32.180]  finalizing server assets 
[19:27:32.180] 
[19:27:32.180] 11:27:32 AM [build] Rearranging server assets...
[19:27:32.392] ▲ [WARNING] Ignoring this import because "node_modules/.pnpm/path-to-regexp@6.2.1/node_modules/path-to-regexp/dist.es2015/index.js" was marked as having no side effects [ignored-bare-import]
[19:27:32.392] 
[19:27:32.393]     dist/entry.mjs:7:7:
[19:27:32.393]       7 │ import 'path-to-regexp';
[19:27:32.393]         ╵        ~~~~~~~~~~~~~~~~
[19:27:32.394] 
[19:27:32.394]   "sideEffects" is false in the enclosing "package.json" file
[19:27:32.394] 
[19:27:32.395]     node_modules/path-to-regexp/package.json:45:2:
[19:27:32.395]       45 │   "sideEffects": false,
[19:27:32.395]          ╵   ~~~~~~~~~~~~~
[19:27:32.395] 
[19:27:32.396] ▲ [WARNING] Ignoring this import because "node_modules/.pnpm/solidjs-use@1.2.0/node_modules/solidjs-use/dist/index.mjs" was marked as having no side effects [ignored-bare-import]
[19:27:32.396] 
[19:27:32.396]     dist/entry.mjs:10:101:
[19:27:32.396]       10 │ ... empty css                                 */import 'solidjs-use';
[19:27:32.396]          ╵                                                        ~~~~~~~~~~~~~
[19:27:32.396] 
[19:27:32.397]   "sideEffects" is false in the enclosing "package.json" file
[19:27:32.397] 
[19:27:32.398]     node_modules/solidjs-use/package.json:30:2:
[19:27:32.398]       30 │   "sideEffects": false,
[19:27:32.399]          ╵   ~~~~~~~~~~~~~
[19:27:32.399] 
[19:27:32.399] ▲ [WARNING] Ignoring this import because "node_modules/.pnpm/eventsource-parser@0.1.0/node_modules/eventsource-parser/dist/index.esm.js" was marked as having no side effects [ignored-bare-import]
[19:27:32.400] 
[19:27:32.400]     dist/entry.mjs:14:57:
[19:27:32.400]       14 │ ...                                    */import 'eventsource-parser';
[19:27:32.401]          ╵                                                 ~~~~~~~~~~~~~~~~~~~~
[19:27:32.401] 
[19:27:32.401]   "sideEffects" is false in the enclosing "package.json" file
[19:27:32.401] 
[19:27:32.401]     node_modules/eventsource-parser/package.json:5:2:
[19:27:32.401]       5 │   "sideEffects": false,
[19:27:32.402]         ╵   ~~~~~~~~~~~~~
[19:27:32.402] 
[19:27:32.443] 11:27:32 AM [build] Server built in 11.80s
[19:27:32.443] 11:27:32 AM [build] Complete!
[19:27:32.571] Build Completed in /vercel/output [31s]
[19:27:39.443] Generated build outputs:
[19:27:39.443]  - Static files: 73
[19:27:39.443]  - Prerenders: 0
[19:27:39.444]  - Serverless Functions: 0
[19:27:39.444]  - Edge Functions: 1
[19:27:39.444] Deployed outputs in 6s
[19:27:39.812] Build completed
[19:27:52.742] Uploading build cache [34.22 MB]...
[19:27:53.885] Build cache uploaded: 1.143s
zydou commented 1 year ago

Hi, I just assigned a new domain without enabling CDN and the new site is functioning properly. It seems that there is a compatibility issue with Cloudflare CDN. If you believe this is a rare case, feel free to close this issue.