fix: use NEXT_PUBLIC_BACKEND_URL if provided

This commit is contained in:
Abhishek Kumar 2026-05-27 14:54:25 +05:30
parent 09fb7d314f
commit 0908df73f8

View file

@ -57,6 +57,15 @@ import {
} from "@/components/ui/table";
import { useAuth } from "@/lib/auth";
const INBOUND_WEBHOOK_PATH = "/api/v1/telephony/inbound/run";
function getInboundWebhookUrl(): string {
const backendUrl =
process.env.NEXT_PUBLIC_BACKEND_URL ||
(typeof window !== "undefined" ? window.location.origin : "");
return `${backendUrl}${INBOUND_WEBHOOK_PATH}`;
}
export default function TelephonyConfigurationDetailPage() {
const router = useRouter();
const params = useParams<{ configId: string }>();
@ -255,16 +264,17 @@ export default function TelephonyConfigurationDetailPage() {
<button
type="button"
onClick={() => {
const url = `${typeof window !== "undefined" ? window.location.origin : ""}/api/v1/telephony/inbound/run`;
const url = getInboundWebhookUrl();
navigator.clipboard
.writeText(url)
.then(() => toast.success("Inbound webhook URL copied"))
.catch(() => toast.error("Failed to copy URL"));
}}
title="Click to copy inbound webhook URL"
aria-label="Copy inbound webhook URL"
className="inline-flex items-center gap-1 self-start rounded font-mono text-xs text-muted-foreground hover:text-foreground"
>
<span className="truncate">/api/v1/telephony/inbound/run</span>
<span className="truncate">{getInboundWebhookUrl()}</span>
<Copy className="h-3 w-3 shrink-0" />
</button>
</div>