mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
feat: add support for self-hosted draw.io via DRAWIO_BASE_URL environment variable (#163)
## Summary
Add support for self-hosted draw.io instances via build-time configuration.
## Problem
In some corporate environments, `embed.diagrams.net` is blocked by network policies.
Users cannot use the application without access to the default draw.io embed URL.
## Solution
- Add `NEXT_PUBLIC_DRAWIO_BASE_URL` environment variable support
- Pass the `baseUrl` prop to the `DrawIoEmbed` component
- Configure Dockerfile to accept build-time argument for the draw.io URL
## Usage
```yaml
# docker-compose.yaml
services:
drawio:
image: jgraph/drawio:latest
ports:
- "8080:8080"
next-ai-draw-io:
build:
context: .
args:
- NEXT_PUBLIC_DRAWIO_BASE_URL=http://drawio:8080
```
Or build directly:
```bash
docker build --build-arg NEXT_PUBLIC_DRAWIO_BASE_URL=http://localhost:8080 -t next-ai-draw-io .
```
**Note:** This is a build-time configuration. To change the draw.io URL, you need to rebuild the Docker image.
This commit is contained in:
@@ -22,6 +22,10 @@ COPY . .
|
||||
# Disable Next.js telemetry during build
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Build-time argument for self-hosted draw.io URL
|
||||
ARG NEXT_PUBLIC_DRAWIO_BASE_URL=https://embed.diagrams.net
|
||||
ENV NEXT_PUBLIC_DRAWIO_BASE_URL=${NEXT_PUBLIC_DRAWIO_BASE_URL}
|
||||
|
||||
# Build Next.js application (standalone mode)
|
||||
RUN npm run build
|
||||
|
||||
|
||||
@@ -126,6 +126,8 @@ Open [http://localhost:3000](http://localhost:3000) in your browser.
|
||||
|
||||
Replace the environment variables with your preferred AI provider configuration. See [Multi-Provider Support](#multi-provider-support) for available options.
|
||||
|
||||
> **Corporate Networks:** If `embed.diagrams.net` is blocked, see [Self-Hosted Draw.io](./docs/self-hosted-drawio.md) for configuration options.
|
||||
|
||||
### Installation
|
||||
|
||||
1. Clone the repository:
|
||||
|
||||
@@ -11,6 +11,9 @@ import {
|
||||
} from "@/components/ui/resizable"
|
||||
import { useDiagram } from "@/contexts/diagram-context"
|
||||
|
||||
const drawioBaseUrl =
|
||||
process.env.NEXT_PUBLIC_DRAWIO_BASE_URL || "https://embed.diagrams.net"
|
||||
|
||||
export default function Home() {
|
||||
const { drawioRef, handleDiagramExport, onDrawioLoad } = useDiagram()
|
||||
const [isMobile, setIsMobile] = useState(false)
|
||||
@@ -109,6 +112,7 @@ export default function Home() {
|
||||
ref={drawioRef}
|
||||
onExport={handleDiagramExport}
|
||||
onLoad={onDrawioLoad}
|
||||
baseUrl={drawioBaseUrl}
|
||||
urlParameters={{
|
||||
ui: drawioUi,
|
||||
spin: true,
|
||||
|
||||
57
docs/self-hosted-drawio.md
Normal file
57
docs/self-hosted-drawio.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Self-Hosted Draw.io Configuration
|
||||
|
||||
In some corporate environments, `embed.diagrams.net` is blocked by network policies. This guide explains how to use a self-hosted draw.io instance with Next AI Draw.io.
|
||||
|
||||
## Configuration
|
||||
|
||||
Set the `NEXT_PUBLIC_DRAWIO_BASE_URL` environment variable to point to your self-hosted draw.io instance. This is a **build-time** configuration, meaning you need to rebuild the Docker image to change the URL.
|
||||
|
||||
## Docker Build
|
||||
|
||||
```bash
|
||||
# Build with custom draw.io URL
|
||||
docker build --build-arg NEXT_PUBLIC_DRAWIO_BASE_URL=http://your-drawio-server:8080 -t next-ai-draw-io .
|
||||
|
||||
# Run the custom build
|
||||
docker run -d -p 3000:3000 --env-file .env next-ai-draw-io
|
||||
```
|
||||
|
||||
## Docker Compose
|
||||
|
||||
```yaml
|
||||
services:
|
||||
drawio:
|
||||
image: jgraph/drawio:latest
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
next-ai-draw-io:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
- NEXT_PUBLIC_DRAWIO_BASE_URL=http://drawio:8080
|
||||
ports:
|
||||
- "3000:3000"
|
||||
env_file:
|
||||
- .env
|
||||
```
|
||||
|
||||
## Running Draw.io Locally
|
||||
|
||||
You can run the official draw.io Docker image:
|
||||
|
||||
```bash
|
||||
docker run -d -p 8080:8080 jgraph/drawio:latest
|
||||
```
|
||||
|
||||
Then build Next AI Draw.io with:
|
||||
|
||||
```bash
|
||||
docker build --build-arg NEXT_PUBLIC_DRAWIO_BASE_URL=http://localhost:8080 -t next-ai-draw-io .
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The default draw.io URL is `https://embed.diagrams.net`
|
||||
- Changes to `NEXT_PUBLIC_DRAWIO_BASE_URL` require rebuilding the Docker image
|
||||
- For local development, you can set this in `.env.local`
|
||||
@@ -60,3 +60,7 @@ AI_MODEL=global.anthropic.claude-sonnet-4-5-20250929-v1:0
|
||||
|
||||
# Access Control (Optional)
|
||||
# ACCESS_CODE_LIST=your-secret-code,another-code
|
||||
|
||||
# Draw.io Configuration (Optional)
|
||||
# NEXT_PUBLIC_DRAWIO_BASE_URL=https://embed.diagrams.net # Default: https://embed.diagrams.net
|
||||
# Use this to point to a self-hosted draw.io instance
|
||||
|
||||
Reference in New Issue
Block a user