diff --git a/docker/.env.example b/docker/.env.example index 27fa1c013..379885e62 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -375,4 +375,8 @@ GID='1000' # Runtime flags for built-in pupeeteer Chromium instance # This is only required on Linux machines running AnythingLLM via Docker # and do not want to use the --cap-add=SYS_ADMIN docker argument -# ANYTHINGLLM_CHROMIUM_ARGS="--no-sandbox,--disable-setuid-sandbox" \ No newline at end of file +# ANYTHINGLLM_CHROMIUM_ARGS="--no-sandbox,--disable-setuid-sandbox" + +# Disable Swagger API documentation endpoint. +# Set to "true" to disable the /api/docs endpoint (recommended for production deployments). +# DISABLE_SWAGGER_DOCS="true" \ No newline at end of file diff --git a/server/.env.example b/server/.env.example index 3dc0bd596..fb47d8d70 100644 --- a/server/.env.example +++ b/server/.env.example @@ -378,4 +378,8 @@ TTS_PROVIDER="native" # This enables HTTP request/response logging in development. Set value to a truthy string to enable, leave empty value or comment out to disable. # ENABLE_HTTP_LOGGER="" # This enables timestamps for the HTTP Logger. Set value to a truthy string to enable, leave empty value or comment out to disable. -# ENABLE_HTTP_LOGGER_TIMESTAMPS="" \ No newline at end of file +# ENABLE_HTTP_LOGGER_TIMESTAMPS="" + +# Disable Swagger API documentation endpoint. +# Set to "true" to disable the /api/docs endpoint (recommended for production deployments). +# DISABLE_SWAGGER_DOCS="true" \ No newline at end of file diff --git a/server/swagger/utils.js b/server/swagger/utils.js index bd8e3e81c..c4ad2705d 100644 --- a/server/swagger/utils.js +++ b/server/swagger/utils.js @@ -9,6 +9,12 @@ function faviconUrl() { } function useSwagger(app) { + if (process.env.DISABLE_SWAGGER_DOCS === "true") { + console.log( + `\x1b[33m[SWAGGER DISABLED]\x1b[0m Swagger documentation is disabled via DISABLE_SWAGGER_DOCS environment variable.` + ); + return; + } app.use('/api/docs', swaggerUi.serve); const options = { customCss: [