0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ruby on railsのAPIでcorsで躓いた

Posted at

Nuxtから新規投稿できない

結論:cors.rbの設定をしていなかった

confug>initializers>cors.rb

cors.rb
#これがデフォルトでコメントアウトされているのでコメントアウト外す
Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    #origins "example.com"
    origins 'http://localhost:3001'#フロントエンドのURLを指定

    resource "*",
      headers: :any,
      methods: [:get, :post, :put, :patch, :delete, :options, :head]
  end
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?