🔧(backend) add MEDIA_BASE_URL setting
The frontend need to know the base url for the media files, 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 media requests, but in development we need to define it to target the nginx server.
This commit is contained in:
@@ -902,6 +902,7 @@ class ConfigView(views.APIView):
|
||||
"""
|
||||
array_settings = [
|
||||
"ENVIRONMENT",
|
||||
"MEDIA_BASE_URL",
|
||||
"LANGUAGES",
|
||||
"LANGUAGE_CODE",
|
||||
"SENTRY_DSN",
|
||||
|
||||
@@ -15,7 +15,10 @@ from core import factories
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
@override_settings(SENTRY_DSN="https://sentry.test/123")
|
||||
@override_settings(
|
||||
SENTRY_DSN="https://sentry.test/123",
|
||||
MEDIA_BASE_URL="http://testserver/",
|
||||
)
|
||||
def test_api_config_anonymous():
|
||||
"""Anonymous users should be allowed to get the configuration."""
|
||||
client = APIClient()
|
||||
@@ -26,10 +29,13 @@ def test_api_config_anonymous():
|
||||
"LANGUAGE_CODE": "en-us",
|
||||
"SENTRY_DSN": "https://sentry.test/123",
|
||||
"ENVIRONMENT": "test",
|
||||
"MEDIA_BASE_URL": "http://testserver/",
|
||||
}
|
||||
|
||||
|
||||
@override_settings(SENTRY_DSN="https://sentry.test/123")
|
||||
@override_settings(
|
||||
SENTRY_DSN="https://sentry.test/123", MEDIA_BASE_URL="http://testserver/"
|
||||
)
|
||||
def test_api_config_authenticated():
|
||||
"""Authenticated users should be allowed to get the configuration."""
|
||||
user = factories.UserFactory()
|
||||
@@ -44,4 +50,5 @@ def test_api_config_authenticated():
|
||||
"LANGUAGE_CODE": "en-us",
|
||||
"SENTRY_DSN": "https://sentry.test/123",
|
||||
"ENVIRONMENT": "test",
|
||||
"MEDIA_BASE_URL": "http://testserver/",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user