- 14 UI pages: all Select a company empty states use VOCAB.company.toLowerCase() - AgentConfigForm: 3 error throws use VOCAB.company - AgentDetail: additional Select a company upload error replaced - CLI run.ts: Starting/Could not locate/failed to start messages use VOCAB.appName - CLI deployment-auth-check: repairHint uses VOCAB.appName - CLI agent-jwt-secret-check: repairHint uses VOCAB.appName - CLI allowed-hostname: restart message uses VOCAB.appName - Added VOCAB import to all files missing it
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import * as p from "@clack/prompts";
|
|
import { VOCAB } from "@paperclipai/branding";
|
|
import pc from "picocolors";
|
|
import { normalizeHostnameInput } from "../config/hostnames.js";
|
|
import { readConfig, resolveConfigPath, writeConfig } from "../config/store.js";
|
|
|
|
export async function addAllowedHostname(host: string, opts: { config?: string }): Promise<void> {
|
|
const configPath = resolveConfigPath(opts.config);
|
|
const config = readConfig(opts.config);
|
|
|
|
if (!config) {
|
|
p.log.error(`No config found at ${configPath}. Run ${pc.cyan("paperclip onboard")} first.`);
|
|
return;
|
|
}
|
|
|
|
const normalized = normalizeHostnameInput(host);
|
|
const current = new Set((config.server.allowedHostnames ?? []).map((value) => value.trim().toLowerCase()).filter(Boolean));
|
|
const existed = current.has(normalized);
|
|
current.add(normalized);
|
|
|
|
config.server.allowedHostnames = Array.from(current).sort();
|
|
config.$meta.updatedAt = new Date().toISOString();
|
|
config.$meta.source = "configure";
|
|
writeConfig(config, opts.config);
|
|
|
|
if (existed) {
|
|
p.log.info(`Hostname ${pc.cyan(normalized)} is already allowed.`);
|
|
} else {
|
|
p.log.success(`Added allowed hostname: ${pc.cyan(normalized)}`);
|
|
p.log.message(
|
|
pc.dim(`Restart the ${VOCAB.appName} server for this change to take effect.`),
|
|
);
|
|
}
|
|
|
|
if (!(config.server.deploymentMode === "authenticated" && config.server.exposure === "private")) {
|
|
p.log.message(
|
|
pc.dim("Note: allowed hostnames are enforced only in authenticated/private mode."),
|
|
);
|
|
}
|
|
}
|
|
|