-
Notifications
You must be signed in to change notification settings - Fork 57
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
'StaticResource' object has no attribute 'add_route' #151
Comments
actually trying to get aiohttp_swagger json file being exposed with CORS headers... def setup_routes(app):
app.router.add_routes(routes)
setup_swagger(app, api_base_url='/api/v2', swagger_url='/api/v2/doc')
cors = aiohttp_cors.setup(app, defaults={
"*": aiohttp_cors.ResourceOptions(
allow_credentials=True,
expose_headers="*",
allow_headers="*",
)
})
for route in list(app.router.routes()):
cors.add(route) |
in #130 author switched to |
Made this as a workaround. Isn't it a bug? def setup_routes(app):
app.router.add_routes(routes)
setup_swagger(app, api_base_url='/api/v2', swagger_url='/api/v2/doc')
cors = aiohttp_cors.setup(app, defaults={
"*": aiohttp_cors.ResourceOptions(
allow_credentials=True,
expose_headers="*",
allow_headers="*",
)
})
for route in list(app.router.routes()):
if not isinstance(route.resource, StaticResource): # <<< WORKAROUND
cors.add(route) |
Discussed on gitter already but I copy the answer for future readers:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when router has a static resource in routes... then this code fails:
https://github.com/aio-libs/aiohttp-cors/blob/master/aiohttp_cors/urldispatcher_router_adapter.py#L341
with:
AttributeError: 'StaticResource' object has no attribute 'add_route'
The text was updated successfully, but these errors were encountered: