add api url

This commit is contained in:
Fredrik Jensen 2026-02-08 11:48:35 +01:00
parent 36f6657be7
commit 1bfd12ceb2
2 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import Fastify from "fastify"; import Fastify from "fastify";
import fastifySwagger from "@fastify/swagger"; import fastifySwagger from "@fastify/swagger";
import { config } from "./config.js";
import { client } from "./db/index.js"; import { client } from "./db/index.js";
import { errorHandler } from "./plugins/error-handler.js"; import { errorHandler } from "./plugins/error-handler.js";
import { authenticate } from "./plugins/authenticate.js"; import { authenticate } from "./plugins/authenticate.js";
@ -24,12 +25,9 @@ export function buildApp() {
description: "Authentication and account management API", description: "Authentication and account management API",
version: "1.0.0", version: "1.0.0",
}, },
servers: [ servers: config.API_URL
{ ? [{ url: config.API_URL, description: "Production server" }]
url: "http://localhost:3000", : [{ url: "http://localhost:3000", description: "Development server" }],
description: "Development server",
},
],
components: { components: {
securitySchemes: { securitySchemes: {
bearerAuth: { bearerAuth: {

View File

@ -6,6 +6,7 @@ const envSchema = z.object({
JWT_SECRET: z.string().min(32), JWT_SECRET: z.string().min(32),
PORT: z.coerce.number().default(3000), PORT: z.coerce.number().default(3000),
HOST: z.string().default("0.0.0.0"), HOST: z.string().default("0.0.0.0"),
API_URL: z.url().optional(),
}); });
const parsed = envSchema.safeParse(process.env); const parsed = envSchema.safeParse(process.env);