我正在努力让gem“rack cors”在当地工作。我用gem'devieve_token_auth'安装了裸rails,用'angular token'安装了angular 7客户端。但安格尔的每一个要求都是投球失误。我已经按照文档配置了rails和rack cors,但它不起作用。这是我的配置
application.rb
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
methods: [:get, :post, :options, :delete, :put]
end
end
如果我列出中间商使用
rails middleware
,
Rack::Cors
排在第二位
use Webpacker::DevServerProxy
但每个请求都会引发以下错误。
Processing by DeviseTokenAuth::SessionsController#create as HTML
Parameters: {"session"=>{}}
HTTP Origin header (http://localhost:4200) didn't match request.base_url (http://localhost:3000)
Completed 422 Unprocessable Entity in 1ms (ActiveRecord: 0.0ms)
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):