Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Server Configuration
# Set the external server URL for proper image/video display in web interface
# If not set or empty, defaults to http://localhost:57988
# Examples:
# SERVER_URL=http://localhost:57988 # Local development (default)
# SERVER_URL=https://jaaz.app # Production with domain
# SERVER_URL=http://192.168.1.100:57988 # Docker on remote server

# Leave empty to use default localhost:57988
SERVER_URL=

# ComfyUI Configuration (if using ComfyUI)
# For Docker, use host.docker.internal to access host machine
# COMFYUI_URL=http://host.docker.internal:8188
14 changes: 14 additions & 0 deletions server/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import os

DEFAULT_PORT = int(os.environ.get('DEFAULT_PORT', 57988))

def get_server_url():
"""Get the server URL from environment or use default localhost"""
# Try environment variable first
server_url = os.environ.get('SERVER_URL')
if server_url and server_url.strip(): # Check for non-empty string
print(f"🔗 Using SERVER_URL: {server_url}")
return server_url.rstrip('/')

# Default to localhost
default_url = f"http://localhost:{DEFAULT_PORT}"
print(f"🔗 Using default server URL: {default_url}")

return default_url
2 changes: 1 addition & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ async def serve_react_app():
import uvicorn
print("🌟Starting server, UI_DIST_DIR:", os.environ.get('UI_DIST_DIR'))

uvicorn.run(socket_app, host="127.0.0.1", port=args.port)
uvicorn.run(socket_app, host="0.0.0.0", port=args.port)
4 changes: 2 additions & 2 deletions server/routers/image_router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi.responses import FileResponse
from fastapi.concurrency import run_in_threadpool
from common import DEFAULT_PORT
from common import DEFAULT_PORT, get_server_url
from tools.utils.image_canvas_utils import generate_file_id
from services.config_service import FILES_DIR

Expand Down Expand Up @@ -91,7 +91,7 @@ async def upload_image(file: UploadFile = File(...), max_size_mb: float = 3.0):
print('🦄upload_image file_path', file_path)
return {
'file_id': f'{file_id}.{extension}',
'url': f'http://localhost:{DEFAULT_PORT}/api/file/{file_id}.{extension}',
'url': f'{get_server_url()}/api/file/{file_id}.{extension}',
'width': width,
'height': height,
}
Expand Down
4 changes: 2 additions & 2 deletions server/tools/comfy_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import traceback
from io import BytesIO
from typing import Annotated, Any, Dict, List, Optional
from common import DEFAULT_PORT
from common import DEFAULT_PORT, get_server_url
from .utils.image_canvas_utils import (
generate_file_id,
generate_new_image_element,
Expand Down Expand Up @@ -250,7 +250,7 @@ async def _run(
canvas_data["data"]["elements"].append(new_element)
canvas_data["data"]["files"][file_id] = file_data

image_url = f"http://localhost:{DEFAULT_PORT}/api/file/{filename}"
image_url = f"{get_server_url()}/api/file/{filename}"

generated_files_info.append(
{
Expand Down
4 changes: 2 additions & 2 deletions server/tools/utils/image_generation_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from typing import Optional, Dict, Any
from common import DEFAULT_PORT
from common import DEFAULT_PORT, get_server_url
from tools.utils.image_utils import process_input_image
from ..image_providers.image_base_provider import ImageProviderBase

Expand Down Expand Up @@ -94,4 +94,4 @@ async def generate_image_with_provider(
session_id, canvas_id, filename, mime_type, width, height
)

return f"image generated successfully ![image_id: {filename}](http://localhost:{DEFAULT_PORT}{image_url})"
return f"image generated successfully ![image_id: {filename}]({get_server_url()}{image_url})"
4 changes: 2 additions & 2 deletions server/tools/video_generation/video_canvas_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from services.config_service import FILES_DIR
from services.db_service import db_service
from services.websocket_service import send_to_websocket, broadcast_session_update # type: ignore
from common import DEFAULT_PORT
from common import DEFAULT_PORT, get_server_url
from utils.http_client import HttpClient
import aiofiles
import mimetypes
Expand Down Expand Up @@ -152,7 +152,7 @@ async def send_video_error_notification(session_id: str, error_message: str) ->

def format_video_success_message(filename: str) -> str:
"""Format success message for video generation"""
return f"video generated successfully ![video_id: {filename}](http://localhost:{DEFAULT_PORT}/api/file/{filename})"
return f"video generated successfully ![video_id: {filename}]({get_server_url()}/api/file/{filename})"


async def process_video_result(
Expand Down