🔧(backend) add COLLABORATION_SERVER_URL setting
The frontend need to know the collab server url, so we need to add a new setting to the backend, in order to expose this value to the frontend. If the setting is not defined, the frontend current domain will be used as the base url. In production this setting do not need to be defined since we have nginx capturing the ws requests, but in development we need to define it to target the collaboration server.
This commit is contained in:
@@ -45,3 +45,6 @@ OIDC_AUTH_REQUEST_EXTRA_PARAMS={"acr_values": "eidas1"}
|
||||
AI_BASE_URL=https://openaiendpoint.com
|
||||
AI_API_KEY=password
|
||||
AI_MODEL=llama
|
||||
|
||||
# Collaboration
|
||||
COLLABORATION_SERVER_URL=ws://localhost:4444
|
||||
|
||||
@@ -902,6 +902,7 @@ class ConfigView(views.APIView):
|
||||
"""
|
||||
array_settings = [
|
||||
"ENVIRONMENT",
|
||||
"COLLABORATION_SERVER_URL",
|
||||
"MEDIA_BASE_URL",
|
||||
"LANGUAGES",
|
||||
"LANGUAGE_CODE",
|
||||
|
||||
@@ -18,6 +18,7 @@ pytestmark = pytest.mark.django_db
|
||||
@override_settings(
|
||||
SENTRY_DSN="https://sentry.test/123",
|
||||
MEDIA_BASE_URL="http://testserver/",
|
||||
COLLABORATION_SERVER_URL="http://testcollab/",
|
||||
)
|
||||
def test_api_config_anonymous():
|
||||
"""Anonymous users should be allowed to get the configuration."""
|
||||
@@ -25,6 +26,7 @@ def test_api_config_anonymous():
|
||||
response = client.get("/api/v1.0/config/")
|
||||
assert response.status_code == HTTP_200_OK
|
||||
assert response.json() == {
|
||||
"COLLABORATION_SERVER_URL": "http://testcollab/",
|
||||
"LANGUAGES": [["en-us", "English"], ["fr-fr", "French"], ["de-de", "German"]],
|
||||
"LANGUAGE_CODE": "en-us",
|
||||
"SENTRY_DSN": "https://sentry.test/123",
|
||||
@@ -34,7 +36,9 @@ def test_api_config_anonymous():
|
||||
|
||||
|
||||
@override_settings(
|
||||
SENTRY_DSN="https://sentry.test/123", MEDIA_BASE_URL="http://testserver/"
|
||||
SENTRY_DSN="https://sentry.test/123",
|
||||
MEDIA_BASE_URL="http://testserver/",
|
||||
COLLABORATION_SERVER_URL="http://testcollab/",
|
||||
)
|
||||
def test_api_config_authenticated():
|
||||
"""Authenticated users should be allowed to get the configuration."""
|
||||
@@ -46,6 +50,7 @@ def test_api_config_authenticated():
|
||||
response = client.get("/api/v1.0/config/")
|
||||
assert response.status_code == HTTP_200_OK
|
||||
assert response.json() == {
|
||||
"COLLABORATION_SERVER_URL": "http://testcollab/",
|
||||
"LANGUAGES": [["en-us", "English"], ["fr-fr", "French"], ["de-de", "German"]],
|
||||
"LANGUAGE_CODE": "en-us",
|
||||
"SENTRY_DSN": "https://sentry.test/123",
|
||||
|
||||
@@ -377,6 +377,11 @@ class Base(Configuration):
|
||||
# Sentry
|
||||
SENTRY_DSN = values.Value(None, environ_name="SENTRY_DSN", environ_prefix=None)
|
||||
|
||||
# Collaboration
|
||||
COLLABORATION_SERVER_URL = values.Value(
|
||||
None, environ_name="COLLABORATION_SERVER_URL", environ_prefix=None
|
||||
)
|
||||
|
||||
# Easy thumbnails
|
||||
THUMBNAIL_EXTENSION = "webp"
|
||||
THUMBNAIL_TRANSPARENCY_EXTENSION = "webp"
|
||||
|
||||
Reference in New Issue
Block a user