简体   繁体   English

无法获取“图像”.net::ERR_CONNECTION_REFUSED (Gitpod)

[英]Cannot get "images" net::ERR_CONNECTION_REFUSED (Gitpod)

On Gitpod , my NextJS frontend is trying to fetch the list of objects which contain "product names" , "prices" and "images" from my Django Rest API backend .Gitpod 上我的 NextJS 前端试图从我的 Django Rest API 后端获取包含“产品名称”“价格”“图像”的对象列表。 Then, my NextJS frontend can get the list of objects which contain "product names" and "prices" but not "images" so my NextJS frontend cannot get only "images" as shown below:然后,我的 NextJS 前端可以获取包含“产品名称”“价格”但不包含“图像”的对象列表,因此我的 NextJS 前端不能仅获取“图像” ,如下所示:

( "product names" such as "boots 4", "boots 3"... and "prices" such as "£12.10", "£10.50"... are displayed but not "images" ) 显示“靴子 4”、“靴子 3”等“产品名称”以及“£12.10”、“£10.50”等“价格”,但不显示“图片”

在此处输入图像描述

This is my desired output with "product names" , "prices" and "images" :这是我想要的 output,带有“产品名称”“价格”“图片”

在此处输入图像描述

On Gitpod , both my NextJS frontend on port 3000 open (private) and my Django Rest API backend on port 8000 open (private) are running:Gitpod上,我在端口 3000 打开(私有)的 NextJS 前端我在端口 8000 打开(私有)的后端 Django Rest API都在运行:

在此处输入图像描述

And my NextJS frontend uses this Rest API call with "localhost" as shown below to get the list of objects which contain "product names" , "prices" and "images" :我的 NextJS 前端使用 Rest API 调用“localhost” ,如下所示,以获取包含“产品名称”“价格”“图像”的对象列表:

http://localhost:8000/api

And, there are these errors:而且,还有这些错误:

3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987
GET http://localhost:8000/media/images/paid.png.net::ERR_CONNECTION_REFUSED 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987获取 http://localhost:8000/media/images/paid.png.net::ERR_CONNECTION_REFUSED 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987
GET http://localhost:8000/media/images/size.png.net::ERR_CONNECTION_REFUSED 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987获取 http://localhost:8000/media/images/size.png.net::ERR_CONNECTION_REFUSED 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987
GET http://localhost:8000/media/images/download.jpg.net::ERR_CONNECTION_REFUSED 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987获取 http://localhost:8000/media/images/download.jpg.net::ERR_CONNECTION_REFUSED 3000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/:987
GET http://localhost:8000/media/images/02173_l.jpg.net::ERR_CONNECTION_REFUSED获取 http://localhost:8000/media/images/02173_l.jpg.net::ERR_CONNECTION_REFUSED

Actually, I solved these errors above by using this Rest API call with my Gitpod domain as shown below to get the list of objects:实际上,我通过使用 Rest API 调用我的 Gitpod 域来解决上面的这些错误,如下所示,以获取对象列表:

https://8000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/api

But other error occurs as shown below:但是出现其他错误,如下所示:

Server Error
FetchError: invalid json response body at https://8000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/api reason: Unexpected end of JSON input

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
pages/index.js (73:16) @ async getStaticProps

  71 | export async function getStaticProps() {
  72 |   const res = await fetch("https://8000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/api");
> 73 |   const posts = await res.json();
     |                ^
  74 | 
  75 |   // const ress = await fetch("http://127.0.0.1:8000/api/category/");
  76 |   // const categories = await ress.json();

Actually, this Rest API call with my Gitpod domain is correct because with this Rest API call, I can get the list of objects on Postman from my Django Rest API backend on Gitpod : Actually, this Rest API call with my Gitpod domain is correct because with this Rest API call, I can get the list of objects on Postman from my Django Rest API backend on Gitpod :

https://8000-gitpodio-templatetypescr-tqzkjl97w1d.ws-us33.gitpod.io/api

Are there any solutions to solve this error and get the list of objects which contain "product names" , "prices" and "images" ?是否有解决此错误并获取包含“产品名称”“价格”“图像”的对象列表的解决方案?

You should make the port 8000 for your Django Rest API backend "public" to get the list of objects which contain "product names" , "prices" and "images" :您应该将8000 端口设置为 Django Rest API 后端“public” ,以获取包含“product names”“prices”“images”的对象列表:

在此处输入图像描述

Finally, you can get the list of objects which contain "product names" , "prices" and "images" :最后,您可以获得包含“产品名称”“价格”“图片”的对象列表:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误选项 net::ERR_CONNECTION_REFUSED - Error OPTIONS net::ERR_CONNECTION_REFUSED Django:ERR_CONNECTION_REFUSED - Django: ERR_CONNECTION_REFUSED jQuery,Ajax(失败)净:: ERR_CONNECTION_REFUSED - Jquery, Ajax (failed) net::ERR_CONNECTION_REFUSED 带有 Selenium 的 StaticLiveServerTestCase:ERR_CONNECTION_REFUSED - StaticLiveServerTestCase with Selenium: ERR_CONNECTION_REFUSED 尝试向 Django REST 服务器发出请求时获取 net::ERR_CONNECTION_REFUSED - Getting net::ERR_CONNECTION_REFUSED when trying to make a request to Django REST Server 为什么我的 Ubuntu Apache 服务器上的 Flask 应用程序得到 ERR_CONNECTION_REFUSED? - Why my Flask application on my Ubuntu Apache server get ERR_CONNECTION_REFUSED? 无法在浏览器上运行 uvicorn.run | ERR_CONNECTION_REFUSED - Not able to get the uvicorn.run running on browser | ERR_CONNECTION_REFUSED 在 Gitlab CI 中为 Django 项目运行 Selenium 测试:ERR_CONNECTION_REFUSED on get live_server_url - Run Selenium tests for Django project in Gitlab CI : ERR_CONNECTION_REFUSED on get live_server_url 使用Heroku问题ERR_CONNECTION_REFUSED部署django - Deploy django with Heroku issue, ERR_CONNECTION_REFUSED 浏览器中的 Ray Dashboard 错误“ERR_CONNECTION_REFUSED” - Ray Dashboard error in the browser “ERR_CONNECTION_REFUSED”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM