Я хочу интегрировать всплывающее окно аутентификации Twitter с React и Rails.Я использую https://github.com/GenFirst/react-twitter-auth
Реактивная реализация
<TwitterLogin
loginUrl="https://api.localhost:3000/v1/twitter_auth_callback"
onFailure={this.handleFailure}
onSuccess={this.handleTwitterResponse}
requestTokenUrl={`https://api.localhost:3000/v1/projects/${projectSlug}/social_accounts/twitter_auth`}
>
cors.rb
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
Все работает нормально, но после успешной аутентификации, всплывающее окно должно автоматически закрыватьсяно это не так.Я отлаживаю react-twitter-auth
и получаю сообщение от консоли chrome:
DOMException: Blocked a frame with origin "https://localhost:3001" from accessing a cross-origin frame.
at https://localhost:3001/static/js/bundle.js:129614:31
Мой rails api работает на https://api.localhost:3000
и реагирует https://localhost:3001
.Что я должен изменить, чтобы получить window.location.hostname
из всплывающего окна (https://github.com/GenFirst/react-twitter-auth/blob/master/src/index.js#L89) и решить CORS
проблему?
PS Я не одинок: https://github.com/GenFirst/react-twitter-auth/issues/21