我无法通过代理访问我的阿波罗服务器

问题描述

我已经在本地主机的端口3000上设置了apollo server,并且工作正常。我可以在操场上进行查询,它们都可以工作。 (为保护隐私,一些文字被像素化了)

enter image description here

但是,我的前端是一个Svelte应用程序,它通过snowpack从本地主机上的端口8080提供服务。我已经将snowpack配置设置为将localhost:8080 / api代理为localhost:3000

  proxy: {
    "/api": "http://localhost:3000/"
  },

如果我尝试通过http:// localhost:8080 / api访问游乐场,则会出现Web UI,但graphql协议似乎存在错误。用户界面抱怨the server cannot be reached

enter image description here

如果我进入开发人员模式,则会看到以下请求失败

POST /api HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 1468
accept: */*
Apollo-Query-Plan-Experimental: 1
X-Apollo-Tracing: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/86.0.4240.198 Safari/537.36
DNT: 1
content-type: application/json
Origin: http://localhost:8080
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:8080/api/
Accept-Encoding: gzip,deflate,br
Accept-Language: en-AU,en;q=0.9,de-AT;q=0.8,de;q=0.7,en-GB;q=0.6,en-US;q=0.5

带有请求正文

enter image description here

返回的响应是

HTTP/1.1 400 Bad Request
connection: close
Date: Thu,12 Nov 2020 18:40:59 GMT
Content-Length: 0

是否需要对服务器进行配置,以使其通过这样的代理工作?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...