AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
tweak(platform): Disable docs endpoint when not local (#8265)
Aarushi2aed470d2610
diff --git a/autogpt_platform/backend/.env.example b/autogpt_platform/backend/.env.exampleindex c2204abaea..ed87d8fb75 100644--- a/autogpt_platform/backend/.env.example+++ b/autogpt_platform/backend/.env.example@@ -98,3 +98,5 @@ ENABLE_CLOUD_LOGGING=falseENABLE_FILE_LOGGING=false# Use to manually set the log directory# LOG_DIR=./logs++APP_ENV=localdiff --git a/autogpt_platform/backend/backend/server/rest_api.py b/autogpt_platform/backend/backend/server/rest_api.pyindex 4378cfb50a..99dba10009 100644--- a/autogpt_platform/backend/backend/server/rest_api.py+++ b/autogpt_platform/backend/backend/server/rest_api.py@@ -51,6 +51,7 @@ class AgentServer(AppService):await db.disconnect()def run_service(self):+ docs_url = "/docs" if settings.config.app_env == "local" else Noneapp = FastAPI(title="AutoGPT Agent Server",description=(@@ -60,6 +61,7 @@ class AgentServer(AppService):summary="AutoGPT Agent Server",version="0.1",lifespan=self.lifespan,+ docs_url=docs_url,)if self._test_dependency_overrides:diff --git a/autogpt_platform/backend/backend/server/ws_api.py b/autogpt_platform/backend/backend/server/ws_api.pyindex 8dfc54239f..039ef718fd 100644--- a/autogpt_platform/backend/backend/server/ws_api.py+++ b/autogpt_platform/backend/backend/server/ws_api.py@@ -28,6 +28,7 @@ async def lifespan(app: FastAPI):event_queue.close()+docs_url = "/docs" if settings.config.app_env == "local" else Noneapp = FastAPI(lifespan=lifespan)event_queue = RedisEventQueue()_connection_manager = Nonediff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.pyindex 071f5a4c1e..06222492b3 100644--- a/autogpt_platform/backend/backend/util/settings.py+++ b/autogpt_platform/backend/backend/util/settings.py@@ -1,5 +1,6 @@import jsonimport os+from enum import Enumfrom typing import Any, Dict, Generic, List, Set, Tuple, Type, TypeVarfrom pydantic import BaseModel, Field, PrivateAttr, field_validator@@ -15,6 +16,12 @@ from backend.util.data import get_config_path, get_data_path, get_secrets_pathT = TypeVar("T", bound=BaseSettings)+class AppEnvironment(str, Enum):+ LOCAL = "local"+ DEVELOPMENT = "dev"+ PRODUCTION = "prod"++class UpdateTrackingModel(BaseModel, Generic[T]):_updated_fields: Set[str] = PrivateAttr(default_factory=set)@@ -121,6 +128,11 @@ class Config(UpdateTrackingModel["Config"], BaseSettings):"This value is then used to generate redirect URLs for OAuth flows.",)+ app_env: AppEnvironment = Field(+ default=AppEnvironment.LOCAL,+ description="The name of the app environment.",+ )+backend_cors_allow_origins: List[str] = Field(default_factory=list)@field_validator("backend_cors_allow_origins")diff --git a/autogpt_platform/market/.env.example b/autogpt_platform/market/.env.exampleindex afaed399ef..5522998fc1 100644--- a/autogpt_platform/market/.env.example+++ b/autogpt_platform/market/.env.example@@ -7,4 +7,6 @@ SENTRY_DSN=https://[email protected].ENABLE_AUTH=trueSUPABASE_JWT_SECRET=our-super-secret-jwt-token-with-at-least-32-characters-long-BACKEND_CORS_ALLOW_ORIGINS="http://localhost:3000,http://127.0.0.1:3000"\ No newline at end of file+BACKEND_CORS_ALLOW_ORIGINS="http://localhost:3000,http://127.0.0.1:3000"++APP_ENV=local\ No newline at end of filediff --git a/autogpt_platform/market/market/app.py b/autogpt_platform/market/market/app.pyindex 785f3d9854..864de8cb85 100644--- a/autogpt_platform/market/market/app.py+++ b/autogpt_platform/market/market/app.py@@ -49,7 +49,7 @@ async def lifespan(app: fastapi.FastAPI):yieldawait db_client.disconnect()-+docs_url = "/docs" if os.environ.get("APP_ENV") == "local" else Noneapp = fastapi.FastAPI(title="Marketplace API",description="AutoGPT Marketplace API is a service that allows users to share AI agents.",@@ -57,6 +57,7 @@ app = fastapi.FastAPI(version="0.1",lifespan=lifespan,root_path="/api/v1/market",+ docs_url=docs_url,)app.add_middleware(fastapi.middleware.gzip.GZipMiddleware, minimum_size=1000)