diff --git a/.env.dev b/.env.dev index d9e2dd3ceb8c2625874cb4f7f902be5ab9c33320..7e9eb3bf153bfa741d1ad369b38c24124ef1cd38 100644 --- a/.env.dev +++ b/.env.dev @@ -9,3 +9,4 @@ FUNKWHALE_PROTOCOL=http PYTHONDONTWRITEBYTECODE=true WEBPACK_DEVSERVER_PORT=8080 MUSIC_DIRECTORY_PATH=/music +BROWSABLE_API_ENABLED=True diff --git a/api/config/settings/common.py b/api/config/settings/common.py index 5fed9f25e86d065aff3b8f4ab662d38c65870aaf..59aa93117e503b08f8a2fa53df8282b4ec0bbf32 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -406,8 +406,18 @@ REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': ( 'rest_framework.filters.OrderingFilter', 'django_filters.rest_framework.DjangoFilterBackend', + ), + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', ) } + +BROWSABLE_API_ENABLED = env.bool('BROWSABLE_API_ENABLED', default=False) +if BROWSABLE_API_ENABLED: + REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] += ( + 'rest_framework.renderers.BrowsableAPIRenderer', + ) + REST_AUTH_SERIALIZERS = { 'PASSWORD_RESET_SERIALIZER': 'funkwhale_api.users.serializers.PasswordResetSerializer' # noqa } diff --git a/changes/changelog.d/205.enhancement b/changes/changelog.d/205.enhancement new file mode 100644 index 0000000000000000000000000000000000000000..b44375b13bed47f72b28bb5cf89acd5ddae65562 --- /dev/null +++ b/changes/changelog.d/205.enhancement @@ -0,0 +1 @@ +Disabled browsable HTML API in production (#205)