Giter Site home page Giter Site logo

Cannot perform update(PUT) action about rack-cors HOT 9 CLOSED

cyu avatar cyu commented on July 23, 2024
Cannot perform update(PUT) action

from rack-cors.

Comments (9)

monfresh avatar monfresh commented on July 23, 2024

@Bunthoeun This is because you need to set up routes that respond to the OPTIONS method. As you can see in the server log, it says::

ActionController::RoutingError (No route matches [OPTIONS] "/sections/3"):

Any time you see that kind of error, it means something is missing or is not set up correctly in your config/routes.rb file. Unfortunately, the fact that you need to set up a route that responds to OPTIONS is not documented in this repo, but I'm working on submitting a pull request that will add that much needed documentation. In the meantime, you can see how to do it here.

from rack-cors.

dmur avatar dmur commented on July 23, 2024

@monfresh good idea on documenting that, I ran into that as well and some documentation would have helped

from rack-cors.

monfresh avatar monfresh commented on July 23, 2024

I will work on the documentation in the next few days.

from rack-cors.

timruffles avatar timruffles commented on July 23, 2024

Is it not a good idea to deal with the OPTIONs in rack-cors? Seems like an incomplete implementation if you need to add OPTION routes everywhere.

from rack-cors.

cyu avatar cyu commented on July 23, 2024

Sorry - I just took a quick look at this. Rack::Cors is handling this correctly. For OPTIONS requests, it's looking for a Access-Control-Allow-Methods method as a hint that it is a preflight request. It'll only pass along the OPTIONS request to the app if that header isn't present. What client are you using to test this?

from rack-cors.

fguillen avatar fguillen commented on July 23, 2024

I'm having the same issue here. I am explicitly sending the header Access-Control-Request-Method but still receiving No route matches [OPTIONS] error:

curl --header "Access-Control-Request-Method: PUT" -I -X OPTIONS http://reportsdashboard-v2.domain.com.dev/api/reports/XXX1

from rack-cors.

aaronromeo avatar aaronromeo commented on July 23, 2024

@fguillen

I had a similar issue. My problem was the order of my middleware (mentioned in the README. As a result, I had to update the first line for my config definition, effectively bumping the Rack::Cors insertion to the top of my middleware stack.

    config.middleware.insert 0, Rack::Cors do
      allow do
        origins '*'

        resource '*',
          :headers => :any,
          :expose  => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
          :methods => [:get, :post, :put, :patch, :delete, :options]
      end
    end

Hope this helps you.

from rack-cors.

fguillen avatar fguillen commented on July 23, 2024

Thanks @aaronromeo I managed to make my config work, it was my mistake, I had forgotten to include :put in my :methods array :/ .. embarrassing, isn't it? :)

from rack-cors.

cyu avatar cyu commented on July 23, 2024

I believe this issue has been addressed by #106. Closing.

from rack-cors.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.