ChatGPTNextWeb / ChatGPT-Next-Web

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

[Bug] Setting environment variables is ineffective #4033

Open Anivie opened 9 months ago

Anivie commented 9 months ago

Describe the bug Try to deploy this app in my vercel, it can runs normally but I found that it will ignore env variable BASE_URL.

To Reproduce Steps to reproduce the behavior:

  1. Go to Vercel
  2. Set env variables "BASE_URL"
  3. Deploy
  4. See error

Expected behavior When sending a request, NextWeb does not send it through the set environment variables. Instead, it initiates the request to the domain name in the webpage.

Screenshots 18718891f9673f1a4d595cead52391c6

Deployment

H0llyW00dzZ commented 9 months ago

this hard to fix for me tbh, because it must dealing with the complexity

alternative to prevent this issue just use a custom url in this settings

image

Anivie commented 9 months ago

this hard to fix for me tbh, because it must dealing with the complexity这对我来说很难修复,因为它必须处理复杂性

alternative to prevent this issue just use a custom url in this settings避免此问题的替代方法是在此设置中使用自定义URL

image

This can solve the problem, but it completely abandons environmental variables. Could you tell me more about 'complexity'?Is this an issue caused by Vercel?

H0llyW00dzZ commented 9 months ago

this hard to fix for me tbh, because it must dealing with the complexity这对我来说很难修复,因为它必须处理复杂性 alternative to prevent this issue just use a custom url in this settings避免此问题的替代方法是在此设置中使用自定义URL image

This can solve the problem, but it completely abandons environmental variables. Could you tell me more about 'complexity'?Is this an issue caused by Vercel?

Not only Vercel , but you'll also need to refactor the codebase. For instance, modifications will be necessary in server.ts and potentially in the LLM API located in router.ts.

anyways its kinda stupid and so bad especially for front end about stupid complexity

H0llyW00dzZ commented 9 months ago

so basically if you want to know about complexity, that's it it literally so hard to maintain, especially fix bugs or improvement

fred-bf commented 9 months ago

@Anivie The reason for this is that forwarding is expected on the nextjs server. This is because if forwarding is not done through the server, which will lead to cross-domain problems.

The current request should be: Client Side(Next.js) → Server Side(Next.js) → Model Provider(e.g. BASE_URL)

fred-bf commented 9 months ago

If you have any other questions about forwarding to 'BASE_URL' through the server, you can continue to add additional comments.

Anivie commented 9 months ago

If you have any other questions about forwarding to 'BASE_URL' through the server, you can continue to add additional comments.

Thank you for your enthusiastic response. I've been trying to pinpoint where the error occurred, but as the gentleman above mentioned, it's quite complex.

H0llyW00dzZ commented 9 months ago

If you have any other questions about forwarding to 'BASE_URL' through the server, you can continue to add additional comments.

Thank you for your enthusiastic response. I've been trying to pinpoint where the error occurred, but as the gentleman above mentioned, it's quite complex.

Hahahaha, Did you find any solution to fix it when trying to pinpoint where the error occurred ?

fred-bf commented 8 months ago

If you have any other questions about forwarding to 'BASE_URL' through the server, you can continue to add additional comments.

Thank you for your enthusiastic response. I've been trying to pinpoint where the error occurred, but as the gentleman above mentioned, it's quite complex.

The behavior meets expectation because NextChat client need to forward request to Next.js server side first to avoid CORS issues, the original 503 error should be coming from the "BASE_URL" server you've configured

bccwuho commented 2 weeks ago

I've met the 520 server error code in this case.