Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch failed when run program #390

Open
cailei0596 opened this issue Apr 30, 2023 · 6 comments
Open

fetch failed when run program #390

cailei0596 opened this issue Apr 30, 2023 · 6 comments
Labels
question Further information is requested

Comments

@cailei0596
Copy link

ubuntu22

leo@leo-virtual-machine:/chatgpt-demo$ node -v
v20.0.0
leo@leo-virtual-machine:
/chatgpt-demo$ npm -v
9.6.4

确认不是网络问题,用代理和不用代理都试过了

[email protected] dev /home/leo/chatgpt-demo

astro dev

🚀 astro v2.1.3 started in 429ms

┃ Local http://localhost:3000/
┃ Network use --host to expose

fetch failed (https://esm.sh/@iconify-json/ph/icons.json)
error fetch failed (https://esm.sh/@iconify-json/ph/icons.json)
File:
/home/leo/chatgpt-demo/node_modules/.pnpm/[email protected]/node_modules/ofetch/dist/shared/ofetch.f223b849.cjs:182:24
Code:
181 | }
> 182 | context.response = await fetch(
| ^
183 | context.request,
184 | context.options
185 | ).catch(async (error) => {
Stacktrace:
FetchError: fetch failed (https://esm.sh/@iconify-json/ph/icons.json)
at async $fetchRaw2 (/home/leo/chatgpt-demo/node_modules/.pnpm/[email protected]/node_modules/ofetch/dist/shared/ofetch.f223b849.cjs:182:24)

error fetch failed (https://esm.sh/@iconify-json/ph/icons.json)
File:
/home/leo/chatgpt-demo/node_modules/.pnpm/[email protected]/node_modules/ofetch/dist/shared/ofetch.f223b849.cjs:182:24
Code:
181 | }
> 182 | context.response = await fetch(
| ^
183 | context.request,
184 | context.options
185 | ).catch(async (error) => {
Stacktrace:
FetchError: fetch failed (https://esm.sh/@iconify-json/ph/icons.json)
at async $fetchRaw2 (/home/leo/chatgpt-demo/node_modules/.pnpm/[email protected]/node_modules/ofetch/dist/shared/ofetch.f223b849.cjs:182:24)
(x2)
^C ELIFECYCLE  Command failed.

@ddiu8081
Copy link
Member

The network request is initiated in the node layer and not in the browser, make sure you have a proxy enabled for node? (e.g. TUN mode for proxy software, or enable terminal proxy).

One way to verify this is to run ping api.openai.com in the terminal to see if the proxy is set up correctly.

@ddiu8081 ddiu8081 added the question Further information is requested label Apr 30, 2023
@ladypiapia
Copy link

ladypiapia commented May 4, 2023

I have encountered the same problem when deploying with Docker ,"fetch failed",I know it’s probably because of proxy.
my trojan config.json on my server like this:

    "run_type": "client",
    "local_addr": "0.0.0.0",
    "local_port": 1080,
    "remote_addr": "61.172.229.205",
    "remote_port": 28101,
    "password": [
        "edfdfaad"
    ]

my docker-compose.yml like this:

version: '3'

services:
  chatgpt-demo:
    image: ddiu8081/chatgpt-demo:latest
    container_name: chatgpt-demo
    restart: always
    ports:
      - '8000:3000'
    environment:
      - OPENAI_API_KEY=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
      - HTTP_PROXY=http://127.0.0.1:1080

I use proxychains
when I run proxychains ping api.openai.comin the terminal ,I get wrong response.But in my other app on my server, I can use openai api normally and proxychains curl api.openai.com command also gets right response .Anithing wrong in my config.json or docker-compose.yml ?
Every thing is fine when running this project on my Mac with Docker Desktop,while on my CentOS server is invalid.Please give me some advice,thanks so much ! @ddiu8081

@xyxbc-git
Copy link

遇到了同样的问题 ,无法解决

@chenyhd
Copy link

chenyhd commented May 25, 2023

@cailei0596 @ladypiapia @xyxbc-git
If you are running the app on your host machine, try using the curl command to access api.open.com and ensure that the network is functioning properly.

If you are running the app on Docker, make sure to configure the proxy settings for Docker. Login to docker and curl api.open.com make sure your setting is correct.

@DylanWyc1
Copy link

I can ping the api.openai.com well. But still got this error, any thoughts or solutions?

@PHIKN1GHT
Copy link

Replace

cdn: 'https://esm.sh/',

in unocss.config.ts with

cdn: 'http://esm.sh/',

can solve this error in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants