首页 > 解决方案 > Heroku Rails 服务器 API 启动时未设置正确的端口号

问题描述

我有一个 Rails API 后端和一个部署到 Heroku 的 React 前端。当我尝试加载调用 API 的页面时,它会挂起,然后最终在控制台中出现此错误:

GET https://MYAPP.herokuapp.com:3001/auth/refresh_token net::ERR_TIMED_OUT

当我在应用程序启动时查看日志时,看起来好像我正在设置3001我想要的端口,但看起来那些 puma 正在侦听不同的端口号:

2020-10-01T04:28:51.720203+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3001} -e ${RACK_ENV:-production}`
2020-10-01T04:28:55.321298+00:00 app[web.1]: Puma starting in single mode...
2020-10-01T04:28:55.321325+00:00 app[web.1]: * Version 4.3.5 (ruby 2.6.6-p146), codename: Mysterious Traveller
2020-10-01T04:28:55.321326+00:00 app[web.1]: * Min threads: 5, max threads: 5
2020-10-01T04:28:55.321326+00:00 app[web.1]: * Environment: production
2020-10-01T04:29:04.625683+00:00 app[web.1]: * Listening on tcp://0.0.0.0:55912

我是否应该将我的提取配置为使用此 URL?:https://MYAPP.herokuapp.com/auth/refresh_token

基本上,我要问的是:基于此日志信息,如果我的 React 应用程序正在侦听,我的 Rails API 在哪里侦听:https://MYAPP.herokuapp.com

标签: ruby-on-railsreactjsheroku

解决方案


推荐阅读