diff --git a/requirements.txt b/requirements.txt index 38d23bdc..113dc83f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,8 @@ django-model-utils==4.3.1 django-redis==5.2.0 django-timezone-field==5.0 djangorestframework==3.14.0 -channels==3.0.4 -channels-redis==3.3.1 +channels==4.0.0 +channels-redis==4.1.0 celery==5.2.7 grpcio==1.54.0 googleapis-common-protos==1.59.0 @@ -25,10 +25,10 @@ SQLAlchemy==2.0.12 django-import-export==3.2.0 requests[socks] python-gnupg==0.5.0 -daphne==3.0.2 +daphne==4.0.0 drf-spectacular==0.26.2 drf-spectacular-sidecar==2023.4.1 -black==23.3.0 +black==22.8.0 isort==5.12.0 flake8==6.0.0 pyflakes==3.0.1 diff --git a/robosats/routing.py b/robosats/routing.py index 61d0282e..2ee7126d 100644 --- a/robosats/routing.py +++ b/robosats/routing.py @@ -1,10 +1,19 @@ +import os + from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter +from django.core.asgi import get_asgi_application import chat.routing +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "robosats.settings") +# Initialize Django ASGI application early to ensure the AppRegistry +# is populated before importing code that may import ORM models. +django_asgi_app = get_asgi_application() + application = ProtocolTypeRouter( { + "http": django_asgi_app, "websocket": AuthMiddlewareStack( URLRouter( chat.routing.websocket_urlpatterns, diff --git a/robosats/settings.py b/robosats/settings.py index 9ef23ca3..28c739e9 100644 --- a/robosats/settings.py +++ b/robosats/settings.py @@ -49,9 +49,11 @@ ALLOWED_HOSTS = [ config("I2P_LONG"), config("LOCAL_ALIAS"), "127.0.0.1", + "localhost", ] CORS_ALLOW_ALL_ORIGINS = True +CSRF_TRUSTED_ORIGINS = ["http://*", "https://*"] # Allows Session Cookie to be read by Javascript on Client side. SESSION_COOKIE_HTTPONLY = False @@ -81,15 +83,16 @@ if os.environ.get("LOG_TO_CONSOLE"): # Application definition INSTALLED_APPS = [ + "daphne", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", + "channels", "django.contrib.staticfiles", "corsheaders", "rest_framework", - "channels", "django_celery_beat", "django_celery_results", "import_export",