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";
|
||||
|
||||
export default function VisualCopilotPage() {
|
||||
return <VisualCopilotModule />;
|
||||
const url = process.env.VIM_URL ?? "";
|
||||
return <VisualCopilotModule url={url} />;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
"use client";
|
||||
|
||||
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() {
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
|
||||
if (!VIM_URL) {
|
||||
export function VisualCopilotModule({ url }: VisualCopilotModuleProps) {
|
||||
if (!url) {
|
||||
return (
|
||||
<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" />
|
||||
@@ -19,9 +18,9 @@ export function VisualCopilotModule() {
|
||||
<p className="mt-1 text-xs">
|
||||
Setează{" "}
|
||||
<code className="rounded bg-muted px-1 py-0.5 text-xs">
|
||||
NEXT_PUBLIC_VIM_URL
|
||||
VIM_URL
|
||||
</code>{" "}
|
||||
în fișierul .env
|
||||
în environment variables (Portainer stack)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -31,23 +30,14 @@ export function VisualCopilotModule() {
|
||||
return (
|
||||
<div className="relative h-full w-full">
|
||||
<iframe
|
||||
src={VIM_URL}
|
||||
src={url}
|
||||
className="h-full w-full border-0"
|
||||
title="Visual CoPilot"
|
||||
allow="fullscreen"
|
||||
/>
|
||||
|
||||
{/* Floating action bar */}
|
||||
<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
|
||||
href={VIM_URL}
|
||||
href={url}
|
||||
target="_blank"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user