Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak(platform): Disable docs endpoint when not local #8265

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions autogpt_platform/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ ENABLE_CLOUD_LOGGING=false
ENABLE_FILE_LOGGING=false
# Use to manually set the log directory
# LOG_DIR=./logs

APP_ENV=local
2 changes: 2 additions & 0 deletions autogpt_platform/backend/backend/server/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async def lifespan(self, _: FastAPI):
await db.disconnect()

def run_service(self):
docs_url = "/docs" if settings.config.app_env == "local" else None
app = FastAPI(
title="AutoGPT Agent Server",
description=(
Expand All @@ -62,6 +63,7 @@ def run_service(self):
summary="AutoGPT Agent Server",
version="0.1",
lifespan=self.lifespan,
docs_url=docs_url
)

if self._test_dependency_overrides:
Expand Down
4 changes: 3 additions & 1 deletion autogpt_platform/backend/backend/server/ws_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ async def lifespan(app: FastAPI):
await event_queue.close()


app = FastAPI(lifespan=lifespan)
docs_url = "/docs" if settings.config.app_env == "local" else None

app = FastAPI(lifespan=lifespan, docs_url=docs_url)
event_queue = AsyncRedisEventQueue()
_connection_manager = None

Expand Down
5 changes: 5 additions & 0 deletions autogpt_platform/backend/backend/util/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ class Config(UpdateTrackingModel["Config"], BaseSettings):
"This value is then used to generate redirect URLs for OAuth flows.",
)

app_env: str = Field(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum

default="local",
description="The name of the app environment.",
)

backend_cors_allow_origins: List[str] = Field(default_factory=list)

@field_validator("backend_cors_allow_origins")
Expand Down
4 changes: 3 additions & 1 deletion autogpt_platform/market/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ SENTRY_DSN=https://[email protected].

ENABLE_AUTH=true
SUPABASE_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"
BACKEND_CORS_ALLOW_ORIGINS="http://localhost:3000,http://127.0.0.1:3000"

APP_ENV=local
3 changes: 2 additions & 1 deletion autogpt_platform/market/market/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ async def lifespan(app: fastapi.FastAPI):
yield
await db_client.disconnect()


docs_url = "/docs" if os.environ.get("APP_ENV") == "local" else None
app = fastapi.FastAPI(
title="Marketplace API",
description="AutoGPT Marketplace API is a service that allows users to share AI agents.",
summary="Maketplace API",
version="0.1",
lifespan=lifespan,
root_path="/api/v1/market",
docs_url=docs_url,
)

app.add_middleware(fastapi.middleware.gzip.GZipMiddleware, minimum_size=1000)
Expand Down
Loading