feat(server): Add API prefix `/api` to prevent route collisions with frontend (#7472)
- Add prefix `/api` to `APIRouter` in server.py - Update API client in Builder - Update default `AGPT_SERVER_URL` in .env.template - Update default `baseUrl` in `AutoGPTServerAPI` constructorpull/7480/head
parent
354e626965
commit
37b7053e14
|
@ -1 +1 @@
|
|||
AGPT_SERVER_URL=http://localhost:8000
|
||||
AGPT_SERVER_URL=http://localhost:8000/api
|
||||
|
|
|
@ -7,7 +7,9 @@ export default class AutoGPTServerAPI {
|
|||
private socket: WebSocket | null = null;
|
||||
private messageHandlers: { [key: string]: (data: any) => void } = {};
|
||||
|
||||
constructor(baseUrl: string = process.env.AGPT_SERVER_URL || "http://localhost:8000") {
|
||||
constructor(
|
||||
baseUrl: string = process.env.AGPT_SERVER_URL || "http://localhost:8000/api"
|
||||
) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.wsUrl = `ws://${new URL(this.baseUrl).host}/ws`;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class AgentServer(AppService):
|
|||
)
|
||||
|
||||
# Define the API routes
|
||||
router = APIRouter()
|
||||
router = APIRouter(prefix="/api")
|
||||
router.add_api_route(
|
||||
path="/blocks",
|
||||
endpoint=self.get_graph_blocks, # type: ignore
|
||||
|
|
Loading…
Reference in New Issue