【问题标题】:CORS issue happening in tubesock管袜中发生的 CORS 问题
【发布时间】:2018-11-12 11:15:52
【问题描述】:

我有一个运行良好的 Sinatra 应用程序。现在要实现 websockets,我正在使用 Tubesock gem 并添加了以下代码

class Server
  def call(env)
    if env["HTTP_UPGRADE"] == 'websocket'
      tubesock = Tubesock.hijack(env)
      tubesock.onmessage do |message|
        puts "Got #{message}"
      end
      tubesock.listen
      [ -1, {}, [] ]
    else
      [404, {'Content-Type' => 'text/plain'}, ['Not Found']]
    end
  end
end

现在它给出了 CORS 错误(跨源错误)。以前它工作正常。有什么建议吗? 谢谢

【问题讨论】:

  • “现在它给出了 CORS 错误(跨源错误)。以前它工作正常。” – 那么问题就在于你在“以前”和“现在”之间所做的更改。

标签: ruby-on-rails ruby rubygems


【解决方案1】:

我能够使用 rack/cors 并解决问题

【讨论】:

    猜你喜欢
    • 2019-10-13
    • 2015-05-08
    • 1970-01-01
    • 2016-08-12
    • 2017-03-18
    • 2021-08-06
    • 1970-01-01
    • 2020-06-01
    • 2022-01-02
    相关资源
    最近更新 更多