Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requests blocked with 'unallowed method' when route has suffix #20

Open
hackedd opened this issue May 14, 2020 · 2 comments
Open

Requests blocked with 'unallowed method' when route has suffix #20

hackedd opened this issue May 14, 2020 · 2 comments

Comments

@hackedd
Copy link

hackedd commented May 14, 2020

When I register a resource with a suffix specified in the add_route call, preflight requests to that resource fail with Aborting response due to unallowed method because _get_resource_methods returns an empty list.

Setting allow_all_methods=True does not help, each request is still checked against the list of methods on the resource.

The example in this gist illustrates the problem. When you run it, it outputs:

Without: ['GET', 'POST']
With suffix: []

Making a CORS POST to /a succeeds, while the same request to /b fails with the unallowed method message.

@hackedd hackedd mentioned this issue May 14, 2020
@MonsterDeveloper
Copy link

Facing the same problem.

@MonsterDeveloper
Copy link

Found a temporary solution.

Clone falcon_cors from GitHub, and in init.py change _get_resource_methods function, so hasattr(resource, 'on_' + method.lower()) becomes next((s for s in dir(resource) if method.lower() in s), None).

Everything it does is searching for request method substring in resource attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants