-
Notifications
You must be signed in to change notification settings - Fork 2
Impossible to support CORS and non-CORS simultaneously? #17
Copy link
Copy link
Open
Description
I have a single app. I want to accept same-origin requests on /foo and cross-origin requests on /bar.
If I do this:
app.use Rack::CorsGateOriginProcessor
app.use Rack::Cors do
allow do
resource /bar, credentials: true, methods: :any
end
end
Rack::CorsGate
Then env['rack.cors'] will be a miss for requests to /foo. That, in turn, will lead to Rack::CorsGate returning a 403.
Shouldn't the logic be more like
def is_allowed(env, origin, method)
return true if @allow_safe && ['GET', 'HEAD'].include?(method.upcase)
return true if !@strict && origin.nil?
return true if same_origin_request?(env) # CorsGate doesn't apply to same-origin requests
env['rack.cors'].hit?
endOr am I completely missing how this is supposed to work?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels