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

Cors related traceback on run_async.py #2944

Open
1 task done
LasseBlaauwbroek opened this issue Apr 29, 2024 · 0 comments
Open
1 task done

Cors related traceback on run_async.py #2944

LasseBlaauwbroek opened this issue Apr 29, 2024 · 0 comments
Labels

Comments

@LasseBlaauwbroek
Copy link

LasseBlaauwbroek commented Apr 29, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm running Sanic as part of a larger async codebase. I'm using the run_async.py example as a blueprint. If you run this code, and visit the website, everything works as normal. However, on every page-load, this traceback is printed:

[2024-04-29 13:41:43 +0200] [34199] [ERROR] Exception occurred in one of response middleware handlers
Traceback (most recent call last):
  File "<..>/venv-311/lib/python3.11/site-packages/sanic/request/types.py", line 402, in respond
    response = await self.app._run_response_middleware(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "_run_response_middleware", line 17, in _run_response_middleware
    from asyncio.futures import Future
                            ^^^^^^^^^^^
  File "<..>/venv-311/lib/python3.11/site-packages/sanic_ext/extensions/http/cors.py", line 54, in _add_cors_headers
    _add_origin_header(request, response)
  File "<..>/venv-311/lib/python3.11/site-packages/sanic_ext/extensions/http/cors.py", line 160, in _add_origin_header
    allow_origins = _get_from_cors_ctx(
                    ^^^^^^^^^^^^^^^^^^^
  File "<..>/venv-311/lib/python3.11/site-packages/sanic_ext/extensions/http/cors.py", line 151, in _get_from_cors_ctx
    value = getattr(request.route.ctx._cors, key, default)
                    ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'types.SimpleNamespace' object has no attribute '_cors'

Code snippet

No response

Expected Behavior

No response

How do you run Sanic?

As a module

Operating System

Linux

Sanic Version

23.12.0

Additional context

No response

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

No branches or pull requests

1 participant