首页 > 解决方案 > 如何修复 net::ERR_CONNECTION_REFUSED?

问题描述

我创建了一个完整的堆栈网站(Spring Boot Rest API + Angular 前端),并将我的 Angular 文件与 Spring Boot jar 文件一起上传到文件管理器中。

前端工作正常,但是即使从 ssh 终端启动 jar 文件,spring boot 后端连接也会被拒绝。角度前端无法使用 API 服务,页面抛出错误消息:

Access to XMLHttpRequest at 'http://localhost:8000/conversion' from origin 'Here it shows my URL' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.

GET http://localhost:8000/conversion net::ERR_CONNECTION_REFUSED

当我从 eclipse 运行 API 并从 Visual Studio 启动网站时,我在本地打开网站(localhost:4200),一切正常,没有错误,并且 API 服务被 angular 前端正确使用。一旦我在 VPS 服务器中部署应用程序,就会出现此问题。

前端根本无法连接到 Spring Boot 后端。我已经做了一些研究,但我没有发现任何与这个特定问题相关的东西。

我怎样才能使这项工作?

标签: angularspring-bootvps

解决方案


推荐阅读