cyu / rack-cors

Rack Middleware for handling Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible.
MIT License
3.26k stars 263 forks source link

Doesn't append Access-Control-Allow-Origin header as response #235

Closed winston0410 closed 1 year ago

winston0410 commented 2 years ago

I have following codes in config/initializers/cors.rb:

Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '*'
    resource '*', headers: :any, methods: :any
  end
end

And when I try to do a request, I cannot see the Access-Control-Allow-Origin header in the response. I am using the latest rack-cors.

davidalejandroaguilar commented 2 years ago

Happened to me and turns out it was my Mac's Airplay Receiver (after Monterrey update) hijacking port 5000, so my app requests were hitting the Mac and of course, no CORS was configured there.

You can disable in System Preferences -> Sharing -> AirPlay Receiver.

More info here: https://developer.apple.com/forums/thread/682332

swathi-ally commented 2 years ago

This is happening for me too. cors version 1.1.1

origin ENV['URL']

but, when the resource is hit, Access-Control-Allow-Origin header is not returned. Am i missing anything here?

MuhammadRazaAslam commented 1 year ago

@cyu I'm also facing the same issue. Can we fix this issue on priority?

cyu commented 1 year ago

I'm closing this issue – there's not enough information to go on from information provided by @winston0410 @swathi-ally and @MuhammadRazaAslam

Make sure you're providing an Origin header when testing – the middleware doesn't do anything unless that is provided.