Supersonic No 'Access-Control-Allow-Origin' header is present on the requested resource

641 Views Asked by At

Trying to create my first hybrid application using AppGyver's Supersonic. It's angular $http request, work good at ios emulator

$http.get('http://localhost:3000/api/get_data').success (data, status) ->
  console.log data

but on android i have problem with CORS, this is error in console i get

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

Having server in Rails, here is controller

after_filter :set_access_control_headers

def set_access_control_headers
  headers['Access-Control-Allow-Origin'] = '*'
  headers['Access-Control-Request-Method'] = '*'
end

And headers sets up good, may be i need to change Supersonic configs? Any one using Supersonic?

1

There are 1 best solutions below

0
On

Have a look at this while facing some error I came across this article. I'm sharing this hoping it will be helpful for others also. http://www.tsheffler.com/blog/?p=428

Also refer this:

http://www.ciiycode.com/0JiNiqePUejg/origin-httplocalhost-is-not-allowed-by-accesscontrolalloworigin-rails-3