angular - 如何修复 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 后端。我已经做了一些研究,但我没有发现任何与这个特定问题相关的东西。
我怎样才能使这项工作?
解决方案
推荐阅读
- elasticsearch - 如何扩展弹性搜索日期范围直方图聚合查询?
- python - Python:在构建器外部实例化类时引发警告
- c++ - 将 bash 参数传递给 C++
- javascript - JS过滤数组与另一个数组的对象
- apache-kafka - Accessing Kafka clusters using DNS
- python - Pytesseract 因 PermissionError 失败:[WinError 5] 由于文件不可删除,访问被拒绝
- c# - TDLib: Download a file without saving to disk
- mysql - 在 MariaDB 中传递命名参数的语法是什么?
- max - 将结果集从用户定义的函数传递到 max() 函数
- laravel - Laravel,迁移关系在某个时间结束