ruby - Rails Cross Origin Headers Set, XMLHttpRequest cannot load http://www.d1.com/sign_in, Origin something is not allowed by Access-Control-Allow-Origin -


i making ajax post request different origin server user logins. have set cross origin headers in application_controller.rb:

def set_access_control_headers    if request.options?     headers['access-control-allow-origin'] = '*'      headers['access-control-request-method'] = '*'     headers['access-control-allow-credentials'] = "true"   end end 

but i'm still getting:

xmlhttprequest cannot load http://www.d1.com/sign_in. origin http://www.d2.com not allowed access-control-allow-origin.  

you aren't setting access-control-allow-origin or access-control-request-method response headers, according current spec.

access-control-allow-origin needs specific domain. if have multiple domains should allowed access, consider using server-side white-list of domains or subdomains match request origin against, , if request origin matches entry in whitelist echo request origin access-control-allow-origin response header value.

and set access-control-request-method response header methods wish allow, e.g.: get, post, options


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -