ruby 机架应用程序错误处理请求{ GET /vite-dev/@vite/client }

wtlkbnrh  于 2023-02-21  发布在  Ruby
关注(0)|答案(1)|浏览(81)

启动rails服务器和vite dev服务器后,当我尝试从浏览器访问rails应用程序时,我收到了以下错误:

#<NoMethodError: undefined method `then' for #<Array:0x00007fb072a3b2c0>>
/home/.rvm/gems/ruby-2.5.3/gems/rack-proxy-0.7.6/lib/rack/proxy.rb:27:in `extract_http_request_headers'
/home/.rvm/gems/ruby-2.5.3/gems/rack-proxy-0.7.6/lib/rack/proxy.rb:115:in `perform_request'
/home/.rvm/gems/ruby-2.5.3/gems/vite_ruby-3.2.14/lib/vite_ruby/dev_server_proxy.rb:20:in `perform_request'
/home/.rvm/gems/ruby-2.5.3/gems/rack-proxy-0.7.6/lib/rack/proxy.rb:87:in `call'```

The versions from my system are below:
ruby is 2.5.3
rails is 5.2.2
node is 14.21.2
npm is 6.14.17
yarn is 1.22.19
vite_ruby is 3.2.14
vite_rails is 3.0.14

The configurations from my system are below:
package.json -
`{
  "devDependencies": {
    "vite": "^4.1.3",
    "vite-plugin-ruby": "^3.1.3"
  },
  "dependencies": {
    "axios": "^1.2.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}`

I tried downgrading the puma and vite and node versions but no luck.
I have posted the config file above as well.
even tried the host as 127.0.0.1 and 0.0.0.0.
1bqhqjot

1bqhqjot1#

then方法是在Ruby 2.6中引入的,但您使用的是Ruby 2.5.3。
这意味着引发错误的rack-proxy gem与旧的Ruby版本不兼容。
Ruby 2.5大约在2年前就已经到了生命周期的尽头。因此,我建议更新到最新的并且仍然维护Ruby的版本。这意味着Ruby 3.0,因为Ruby 2.7也将在大约7周后到生命周期的尽头。
但是这会导致另一个问题,你仍然在运行Ruby on Rails 5.2,它已经过时了一段时间,而且Ruby on Rails与Ruby〉= 2.7不兼容,这意味着你也需要更新Ruby on Rails。
另一种选择可能是尝试从应用程序中删除对rack-proxy gem的依赖,或者将rack-proxy降级到Ruby 2.5仍在维护时的最新版本,如~> 0.6.0

相关问题