From 1bfd12ceb22b8e54cbe88c3de94ae2cc0d684f58 Mon Sep 17 00:00:00 2001 From: Fredrik Jensen Date: Sun, 8 Feb 2026 11:48:35 +0100 Subject: [PATCH] add api url --- src/app.ts | 10 ++++------ src/config.ts | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app.ts b/src/app.ts index 6e7504e..3b258a7 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,6 @@ import Fastify from "fastify"; import fastifySwagger from "@fastify/swagger"; +import { config } from "./config.js"; import { client } from "./db/index.js"; import { errorHandler } from "./plugins/error-handler.js"; import { authenticate } from "./plugins/authenticate.js"; @@ -24,12 +25,9 @@ export function buildApp() { description: "Authentication and account management API", version: "1.0.0", }, - servers: [ - { - url: "http://localhost:3000", - description: "Development server", - }, - ], + servers: config.API_URL + ? [{ url: config.API_URL, description: "Production server" }] + : [{ url: "http://localhost:3000", description: "Development server" }], components: { securitySchemes: { bearerAuth: { diff --git a/src/config.ts b/src/config.ts index 53f798c..39fedef 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,6 +6,7 @@ const envSchema = z.object({ JWT_SECRET: z.string().min(32), PORT: z.coerce.number().default(3000), HOST: z.string().default("0.0.0.0"), + API_URL: z.url().optional(), }); const parsed = envSchema.safeParse(process.env);