Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Csrf #99

Closed
FredHasselot opened this issue Apr 5, 2016 · 2 comments
Closed

Csrf #99

FredHasselot opened this issue Apr 5, 2016 · 2 comments

Comments

@FredHasselot
Copy link

I've got probably a dumb question but...

i get a CRSF error with a POST request on http://localhost:5000/members/sign_in.json

myApp. config(function(AuthProvider, AuthInterceptProvider) { AuthProvider.loginMethod('POST'); AuthProvider.loginPath('http://localhost:5000/members/sign_in.json'); });

here is the message on chrome console:
XMLHttpRequest cannot load http://localhost:5000/members/sign_in.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 404.

i tried to install the gem 'angular_rails_csrf' on rails.
i tried to follow the post mentioned in the documentation

but... i'm stuck

i misunderstood things.
Any help would be appreciate
thanks

@danielolivaresd
Copy link

This looks like a CORS issue, not a CSRF one. Could you please take a look at https://github.com/cyu/rack-cors and set your client on the origins? Example given:

module YourApp
  class Application < Rails::Application

    # ...

    config.middleware.insert_before 0, "Rack::Cors" do
      allow do
        origins 'http://localhost:9000'
        resource '*', :headers => :any, :methods => [:get, :post, :options]
      end
    end

  end
end

@FredHasselot
Copy link
Author

Absolutly. Thanks!
I did something like this:

  # ...

  allow do
    origins 'localhost:9000', '127.0.0.1:9000',
        resource '*', :headers => :any, :methods => [:get, :post, :delete, :put, :patch, :options, :head]
  end

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants