lynndylanhurley / lynndylanhurley/devise_token_auth
301 redirects and CORS issues
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 3.6k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting the following error making request :(
I'm following guidelines set in the fetch api spec... any clue how to get around this?
XMLHttpRequest cannot load http://localhost:3000/auth/facebook?code={thecode} Redirect from 'http://localhost:3000/auth/facebook?code=[thecode]' to 'http://localhost:3000/omniauth/facebook?code=A[thecode]&resource_class=User' has been blocked by CORS policy: Request requires preflight, which is disallowed to follow cross-origin redirect.
# config/initializers/cors.rb
Rails.application.config.middleware.insert_before ActionDispatch::Static, Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
resource: '*',
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with config/initializers/cors.rb and trace the request from /auth/facebook to /omniauth/facebook, including the 301 redirect and its query parameters. Reproduce the XMLHttpRequest failure locally and determine whether the redirect and CORS behavior can be made compatible; done means the request no longer fails with the reported cross-origin redirect error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100