Search code examples
djangowebsocketdjango-channels

TypeError: AuthMiddlewareStack() missing 1 required positional argument: 'inner'


Hi I am trying to build ASGI APPLICATION but I get this error

File "/home/marwan/Desktop/Gowd/gowd_project/config/routing.py", line 8, in <module>
    AuthMiddlewareStack(
TypeError: AuthMiddlewareStack() missing 1 required positional argument: 'inner'

and this is my routing.py file

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
from django.urls import path

application = ProtocolTypeRouter({
    'websocket': AllowedHostsOriginValidator(
        AuthMiddlewareStack(
            # URLRouter([...]) # Empty for now because we don't have a consumer yet.
        )
    )
})

Solution

  • try below code

    application = ProtocolTypeRouter({
        'websocket': AllowedHostsOriginValidator(
            AuthMiddlewareStack(
                URLRouter([])
            )
        ),
    })