fix: VIM_URL as runtime server-side env var (not build-time NEXT_PUBLIC_)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
|
// Server Component — citește VIM_URL la runtime (nu la build time)
|
||||||
import { VisualCopilotModule } from "@/modules/visual-copilot";
|
import { VisualCopilotModule } from "@/modules/visual-copilot";
|
||||||
|
|
||||||
export default function VisualCopilotPage() {
|
export default function VisualCopilotPage() {
|
||||||
return <VisualCopilotModule />;
|
const url = process.env.VIM_URL ?? "";
|
||||||
|
return <VisualCopilotModule url={url} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ExternalLink, AlertTriangle, Maximize2 } from "lucide-react";
|
import { ExternalLink, AlertTriangle, Maximize2 } from "lucide-react";
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
const VIM_URL = process.env.NEXT_PUBLIC_VIM_URL ?? "";
|
interface VisualCopilotModuleProps {
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
export function VisualCopilotModule() {
|
export function VisualCopilotModule({ url }: VisualCopilotModuleProps) {
|
||||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
if (!url) {
|
||||||
|
|
||||||
if (!VIM_URL) {
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col items-center justify-center gap-4 text-muted-foreground">
|
<div className="flex h-full flex-col items-center justify-center gap-4 text-muted-foreground">
|
||||||
<AlertTriangle className="h-8 w-8 text-amber-500" />
|
<AlertTriangle className="h-8 w-8 text-amber-500" />
|
||||||
@@ -19,9 +18,9 @@ export function VisualCopilotModule() {
|
|||||||
<p className="mt-1 text-xs">
|
<p className="mt-1 text-xs">
|
||||||
Setează{" "}
|
Setează{" "}
|
||||||
<code className="rounded bg-muted px-1 py-0.5 text-xs">
|
<code className="rounded bg-muted px-1 py-0.5 text-xs">
|
||||||
NEXT_PUBLIC_VIM_URL
|
VIM_URL
|
||||||
</code>{" "}
|
</code>{" "}
|
||||||
în fișierul .env
|
în environment variables (Portainer stack)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,23 +30,14 @@ export function VisualCopilotModule() {
|
|||||||
return (
|
return (
|
||||||
<div className="relative h-full w-full">
|
<div className="relative h-full w-full">
|
||||||
<iframe
|
<iframe
|
||||||
src={VIM_URL}
|
src={url}
|
||||||
className="h-full w-full border-0"
|
className="h-full w-full border-0"
|
||||||
title="Visual CoPilot"
|
title="Visual CoPilot"
|
||||||
allow="fullscreen"
|
allow="fullscreen"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Floating action bar */}
|
|
||||||
<div className="absolute bottom-4 right-4 flex items-center gap-1.5">
|
<div className="absolute bottom-4 right-4 flex items-center gap-1.5">
|
||||||
<button
|
|
||||||
onClick={() => setIsFullscreen(!isFullscreen)}
|
|
||||||
className="flex items-center gap-1.5 rounded-md bg-background/80 px-2 py-1.5 text-xs text-muted-foreground backdrop-blur transition-colors hover:text-foreground"
|
|
||||||
title="Deschide fullscreen"
|
|
||||||
>
|
|
||||||
<Maximize2 className="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
<a
|
<a
|
||||||
href={VIM_URL}
|
href={url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-1.5 rounded-md bg-background/80 px-2 py-1.5 text-xs text-muted-foreground backdrop-blur transition-colors hover:text-foreground"
|
className="flex items-center gap-1.5 rounded-md bg-background/80 px-2 py-1.5 text-xs text-muted-foreground backdrop-blur transition-colors hover:text-foreground"
|
||||||
|
|||||||
Reference in New Issue
Block a user