Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add new POWERSYNC_URL_PATH config option
Roland Geider3ec321c34dd3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 61d72dd6d..4547501f8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,4 +12,6 @@ The type for the ID for Measurement and MeasurementCategory was changed from intto UUID. This was made to allow for clients to generate IDs locally and affects`/api/v2/measurement-category/` and `/api/v2/measurement/`.+Make sure you have set the values for `SITE_URL`.+## Othersdiff --git a/settings/main.py b/settings/main.pyindex dd04c9a67..32c4892ea 100644--- a/settings/main.py+++ b/settings/main.py@@ -102,7 +102,8 @@ if not SECRET_KEY or (SECRET_KEY in _DEFAULT_KEYS and not DEBUG):# PowerSyncPOWERSYNC_JWKS_PUBLIC_KEY = env.str('POWERSYNC_JWKS_PUBLIC_KEY', '')POWERSYNC_JWKS_PRIVATE_KEY = env.str('POWERSYNC_JWKS_PRIVATE_KEY', '')-POWERSYNC_URL = env.str('POWERSYNC_URL', 'http://localhost:8000')+POWERSYNC_URL_PATH = env.str('POWERSYNC_URL_PATH', 'ps')+POWERSYNC_URL = env.str('POWERSYNC_URL', '')if not DEBUG and any(POWERSYNC_JWKS_PUBLIC_KEY and hashlib.sha256(key.encode()).hexdigest() in _DEFAULT_POWERSYNC_KEY_HASHESfor key in (POWERSYNC_JWKS_PUBLIC_KEY, POWERSYNC_JWKS_PRIVATE_KEY)diff --git a/wger/core/api/views.py b/wger/core/api/views.pyindex f74d12db5..0361ddbc2 100644--- a/wger/core/api/views.py+++ b/wger/core/api/views.py@@ -450,10 +450,17 @@ def check_language(request):@api_view()@permission_classes([IsAuthenticated])def get_powersync_token(request):++ url = (+ f'{settings.SITE_URL}/{settings.POWERSYNC_URL_PATH.strip("/")}/'+ if not settings.POWERSYNC_URL+ else settings.POWERSYNC_URL+ )+return JsonResponse({'token': powersync.create_token(request.user.id),- 'powersync_url': settings.POWERSYNC_URL,+ 'powersync_url': url,})diff --git a/wger/core/management/commands/setup-powersync-storage.py b/wger/core/management/commands/setup-powersync-storage.pyindex 1a3cc2eee..f72dc7da4 100644--- a/wger/core/management/commands/setup-powersync-storage.py+++ b/wger/core/management/commands/setup-powersync-storage.py@@ -93,7 +93,7 @@ class Command(BaseCommand):self.style.ERROR(f"PS_STORAGE_PG_URI targets database '{target_db}' but Django is "f"connected to '{wger_db}'. Bootstrap that database manually: "- "https://docs.powersync.com/configuration/powersync-service/self-hosted-instances#postgres-storage"+ 'https://docs.powersync.com/configuration/powersync-service/self-hosted-instances#postgres-storage'))return