-
Notifications
You must be signed in to change notification settings - Fork 150
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
Route_prefix breaks the cors check #550
Comments
Maybe I should add, that it happens on views where we define custom options methods. |
Hello @fizyk thank you for reaching out. You can copy an existing CORS tests from here: https://github.com/Cornices/cornice/blob/master/tests/test_cors.py |
Thanks @Natim I'm not sure why, I'm having issues with identifying what and where to initialize in tests to actually achive the results we have. What I can defnitely tell from my debugging is that the
(We do create pyramid routes first)
either pattern, or route name prefixed with cornice, and with route_prefix there's the prefix added, which isn't used in this flow. This MIGHT be the underlying cause of our current issue given the workarounds we've aded earlier 🤔but it might not. At the moment, I'm not able to reproduce the same issue in cornice tests though. |
I released a new version with your changes. Let us know if it fixed the issue on your side. We can rollout a bug fix release anytime |
This fixed the main issue we've had :) from typing import Any, Dict, Optional
from cornice import current_service
from cornice.cors import get_cors_preflight_view
from pyramid.request import Request
from pyramid.view import forbidden_view_config
@forbidden_view_config(renderer="json")
def forbidden_view(request: Request) -> Optional[Dict[str, Any]]:
"""Set proper response status code."""
# Preflight request for endpoint with options method defined
# and requiring authentication
if not request.authorization and request.method == "OPTIONS":
service = current_service(request)
return get_cors_preflight_view(service)(request) I wonder it that would be something that cornice could handle automatically... |
I'm having an issue with route_prefix and cors matching a service through url.
We're running the application in several setups.
We're running it either behind a single nginx that serves both: UI on the root path and pyramid app behind am api prefix or in more like dev environment on different ports. While the single host works great, the separate ports deployment causes an issue in that endpoints are not passing CORS check correctly from the UI. If I remove the route_prefix, everything works correctly and I'm not sure what's happening here.
The text was updated successfully, but these errors were encountered: