diff --git a/api/src/routers/apiRouter.ts b/api/src/routers/apiRouter.ts index a7667732d..d67f12230 100644 --- a/api/src/routers/apiRouter.ts +++ b/api/src/routers/apiRouter.ts @@ -1,21 +1,16 @@ import { OpenAPIHono } from "@hono/zod-openapi"; import { swaggerUI } from "@hono/swagger-ui"; import routesV1 from "../routes/v1"; -import { isProd } from "@src/utils/constants"; +import { env } from "@src/utils/env"; export const apiRouter = new OpenAPIHono(); function registerApiVersion(version: string, baseRouter: OpenAPIHono, versionRoutes: OpenAPIHono[]) { const versionRouter = new OpenAPIHono(); - const servers = [{ url: `https://api.cloudmos.io/${version}`, description: "Production" }]; - if (!isProd) { - servers.unshift({ url: `http://localhost:3080/${version}`, description: "Localhost" }); - } - versionRouter.doc(`/doc`, { openapi: "3.0.0", - servers: servers, + servers: [{ url: `${env.ServerOrigin}/${version}` }], info: { title: "Cloudmos API", description: "Access Akash data from our indexer", diff --git a/api/src/routers/internalRouter.ts b/api/src/routers/internalRouter.ts index 5538d976b..244781132 100644 --- a/api/src/routers/internalRouter.ts +++ b/api/src/routers/internalRouter.ts @@ -1,18 +1,13 @@ -import { isProd } from "@src/utils/constants"; import { OpenAPIHono } from "@hono/zod-openapi"; import { swaggerUI } from "@hono/swagger-ui"; import routes from "../routes/internal"; +import { env } from "@src/utils/env"; export const internalRouter = new OpenAPIHono(); -const servers = [{ url: `https://api.cloudmos.io/internal`, description: "Production" }]; -if (!isProd) { - servers.unshift({ url: `http://localhost:3080/internal`, description: "Localhost" }); -} - internalRouter.doc(`/doc`, { openapi: "3.0.0", - servers: servers, + servers: [{ url: `${env.ServerOrigin}/internal` }], info: { title: "Cloudmos Internal API", description: "APIs for internal use that are not part of the public API. There is no garantees of stability or backward compatibility.", diff --git a/api/src/utils/env.ts b/api/src/utils/env.ts index cf76024a9..a75a58aa6 100644 --- a/api/src/utils/env.ts +++ b/api/src/utils/env.ts @@ -17,6 +17,7 @@ export const env = z UserDatabaseCS: z.string().optional(), Network: z.string().default("mainnet"), RestApiNodeUrl: z.string().optional(), + ServerOrigin: z.string().optional().default("http://localhost:3080"), AkashlyticsGithubPAT: z.string().optional(), Auth0JWKSUri: z.string().optional(), Auth0Audience: z.string().optional(),