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

Controller still executes the request although CORS is blocked for this source #239

Closed jhintringer closed 1 year ago

jhintringer commented 2 years ago

How can I stop executing the request if CORS do not match? The client will nevertheless receive no content, but the code may already do some changes or need performance for that call.

cyu commented 1 year ago

You should be able to do something like this:


request.env['x-rack-cors'].hit?