Closed MacDada closed 8 years ago
Do you mind sharing what it is you need access to these functions for?
Do you mind sharing what it is you need access to these functions for?
@jdesrosiers I have a filter that validates the right app that is "talking" to my REST(y) API. It must ignore preflight requests, as browsers don't send my custom headers:
$app->before(function (Request $request) use ($app) {
$apiClient = $request->headers->get('X-Api-Client');
if (!in_array($apiClient, $app['valid_api_clients'])
&& !(isset($app['cors']) && $app['cors']->isPreflightRequest($request))
) {
return new JsonResponse(['api_client' => 'access_denied'], 403);
}
}, App::EARLY_EVENT);
So, to be precise, I only need isPreflightRequest()
, but I thought it would be useful to use isCorsRequest()
as well (for some people, for me in the future? for logging?).
Closing issue because we are taking another approach. See #24
Hi,
I need to use
isCorsRequest()
andisPreflightRequest()
in my code, outside of theCors
class. I could just copy–paste them, but it would be nice to just reuse existing implementation.BTW, we could make them static, as they don't contain any object state logic.