Rails,无“访问控制允许来源”

时间:2018-07-12 06:32:10

标签: ruby-on-rails ruby-on-rails-5 rails-api

我在Angular上有一些应用程序,它使用服务器Ruby on Rails / oAuth后端。在控制台中注册用户时,出现这些错误。

POST*.herokuapp.com/api/users 500 (Internal Server Error)  *.herokuapp.com/api/users:1 
Failed to load *.herokuapp.com/api/users: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '*.herokuapp.com' is therefore not allowed access. The response had HTTP status code 500.   /registration:1 

{
 "isTrusted": true     /auth.ts:95
}

以及其他发生的错误

{"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}
Error: Uncaught (in promise): {"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}

这是我的应用程序。rb

 require_relative 'boot'
 require 'rails/all'

 # Require the gems listed in Gemfile, including any gems
 # you've limited to :test, :development, or :production.
 Bundler.require(*Rails.groups)

 module Dkeeper
   class Application < Rails::Application
     config.middleware.use Rack::Cors do
       allow do
         origins '*'
         resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
       end
     end
   end
 end

登录时,该用户已添加到数据库中,但是在控制台中出现错误。

谢谢您的帮助。

0 个答案:

没有答案
相关问题