Giter Site home page Giter Site logo

Comments (1)

singfoom avatar singfoom commented on July 23, 2024

I apologize if this is the wrong place to ask this, but I'm having this exact issue and I wanted to ask...
This is my block for the cors configuration, adding the subdomains like your applications above, as well as some localhosts for development in different apps...

    config.middleware.use Rack::Cors do
      allow do
        origins 'http://subdomain1.foo.com', 'http://localhost:3000', 'http://localhost:63342', 'http://localhost', 'http://subdomain2.foo.com'
        resource '*', 
          :headers => :any, 
          :methods => [:get, :post, :options, :delete, :put]
      end
    end

I don't think it's a good solution to use "*" as the origin as I only want my API accessible to the apps that are authorized to use it. Yet, looking at the CORS spec, it will only return one URL at a time. So what's the solution to allow multiple origins to hit the same Rack::CORS enabled service? I saw the previous issue of #30 which had a comment suggesting the use of *.domain.com to address this.

What's the best way to address this in the config?

UPDATE (same day):

I have this 95% solved by setting the :max_age => 0. That avoids caching the Allow-Access-Control-Origin when you switch from one internal app to another. Leaving this here in case someone else has the same problem.

That said, the '*.subdomain.foo" had the effect of not working for any of the subdomains...

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.