4

I am trying to integrate omniauth google oath and while i can log in or create new user through google plus, i get this message when i click login but then disappears at the end of the request.

XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=924…scope=email+profile&state=7569c82117b4114fa45f63db7a7fe80f2c42232524224f2c.


No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:3000' is therefore not allowed access.

Also while on localhost i can create or login using google plus despite the error it doesn't work on heroku.

I've searched a lot but even though i added code like below in my application.rb file

headers['Access-Control-Allow-Origin'] = 'http://localhost:3000'

i still can't seem to get it right

Petros Kyriakou
  • 5,214
  • 4
  • 43
  • 82
  • This question is answered elsewhere: http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource – Ian Selby Aug 06 '15 at 22:58
  • i am talking about rails not javascript. i don't have anywhere javascript code written. – Petros Kyriakou Aug 06 '15 at 22:59
  • Where did you get this message from, specifically? Your browser's console, Rails log file? – EugZol Aug 06 '15 at 23:25
  • in console, and after the refresh it disappears. Obviously there is an ajax request but note that i am using the omniauth google oauth2 gem.i haven't add any javascript. – Petros Kyriakou Aug 06 '15 at 23:31

1 Answers1

0

To have access-control-allow-orgin. You can go through this link below https://github.com/cyu/rack-cors

Just you have to do gem install rack-cors

and then for configuration follow the docs from github link . this might help your problem

Krishna S
  • 27
  • 3