前回記事のRailsバージョンをVueで表示する際、
http://localhost:8080からhttp://localhost:3000がクロスドメイン通信になっており、CORSへの対応が必要でした。
今回CORSへの対応をrack-corsでの対応を試しました。
参考サイト:https://qiita.com/tanshio/items/f35efa7321066d60fc62
group :development, :test do gem 'rack-cors', :require => 'rack/cors' end
bundle installする
~~省略~~ # Don't generate system test files. config.generators.system_tests = nil if Rails.env.development? config.middleware.insert_before ActionDispatch::Static, Rack::Cors do allow do origins '*' resource '*', :headers => :any, :methods => [:get, :post, :options, :patch, :delete] end end end end end
エラーが出ず、バージョンが表示されていることを確認しました。
ソースはこちら(GitHub)