Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

1.2 KB
Raw Blame
import { z } from "zod/v4";

import { createBooleanSchema, createEnv } from "@homarr/core/infrastructure/env";
import { normalizeHttpUrl } from "@homarr/workshop/schema";

const publicHttpUrl = (variableName: string) =>
  z.string().transform((value, context) => {
    try {
      return normalizeHttpUrl(value, variableName);
    } catch (error) {
      context.addIssue({
        code: "custom",
        message: error instanceof Error ? error.message : `${variableName} is invalid`,
      });
      return z.NEVER;
    }
  });

const publicHttpOrigin = (variableName: string) =>
  publicHttpUrl(variableName).refine(
    (value) => value === new URL(value).origin,
    `${variableName} must be an HTTP(S) origin without a path`,
  );

export const env = createEnv({
  server: {
    BASE_URL: publicHttpOrigin("BASE_URL").optional(),
    UNSAFE_ENABLE_MOCK_INTEGRATION: createBooleanSchema(false),
    DEMO_MODE: createBooleanSchema(false),
    DEMO_READ_ONLY: createBooleanSchema(true),
    HOMARR_WEBSITE_URL: publicHttpUrl("HOMARR_WEBSITE_URL").default("https://homarr.dev"),
    WORKSHOP_API_URL: publicHttpUrl("WORKSHOP_API_URL").optional(),
    WORKSHOP_WEB_URL: publicHttpUrl("WORKSHOP_WEB_URL").optional(),
  },
  experimental__runtimeEnv: process.env,
});