From 8fbf29fc45f0642d5e07b292b36ed4ea66cf0517 Mon Sep 17 00:00:00 2001 From: Andreas Dueren Date: Fri, 1 Aug 2025 13:46:17 -0600 Subject: [PATCH] Fix API endpoint configuration and domain references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change NEXT_PUBLIC_ENTE_ENDPOINT to relative /api for domain flexibility - Remove runtime JS endpoint replacement (fragile, now unnecessary) - Fix all domain references to use CLOUDRON_APP_DOMAIN consistently - Add /ping health check endpoint to Caddy configuration - Update placeholder server to use dynamic domain Photos app now working, other apps may need additional fixes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CloudronManifest.json | 2 +- Dockerfile | 6 +++--- start.sh | 49 +++++++++++++++++++------------------------ 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index 49c68b0..11cfa9c 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -7,7 +7,7 @@ "contactEmail": "contact@ente.io", "tagline": "Open Source End-to-End Encrypted Photos & Authentication", "upstreamVersion": "1.0.0", - "version": "0.1.62", + "version": "0.1.63", "healthCheckPath": "/ping", "httpPort": 3080, "memoryLimit": 1073741824, diff --git a/Dockerfile b/Dockerfile index 54d8e3f..beb3728 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,10 +28,10 @@ RUN apt-get update && apt-get install -y git && \ RUN corepack enable # Set environment variables for web app build -# Set the API endpoint to use current origin - this will work at runtime -ENV NEXT_PUBLIC_ENTE_ENDPOINT="https://example.com/api" +# Use relative API endpoint so it works with any domain +ENV NEXT_PUBLIC_ENTE_ENDPOINT="/api" # Add a note for clarity -RUN echo "Building with placeholder NEXT_PUBLIC_ENTE_ENDPOINT, will be served by Caddy proxy at /api" +RUN echo "Building with relative NEXT_PUBLIC_ENTE_ENDPOINT=/api, will be served by Caddy proxy" # Debugging the repository structure RUN find . -type d -maxdepth 3 | sort diff --git a/start.sh b/start.sh index f9eacc3..d1fd147 100644 --- a/start.sh +++ b/start.sh @@ -136,13 +136,19 @@ email: port: ${CLOUDRON_MAIL_SMTP_PORT:-25} username: "${CLOUDRON_MAIL_SMTP_USERNAME:-}" password: "${CLOUDRON_MAIL_SMTP_PASSWORD:-}" - from: "${CLOUDRON_MAIL_FROM:-no-reply@${CLOUDRON_APP_FQDN:-localhost}}" + from: "${CLOUDRON_MAIL_FROM:-no-reply@${CLOUDRON_APP_DOMAIN:-localhost}}" # WebAuthn configuration for passkey support webauthn: - rpid: "${CLOUDRON_APP_FQDN:-localhost}" + rpid: "${CLOUDRON_APP_DOMAIN:-localhost}" rporigins: - - "https://${CLOUDRON_APP_FQDN:-localhost}" + - "https://${CLOUDRON_APP_DOMAIN:-localhost}" + +# Additional Museum server configuration +http: + allowed_hosts: + - "${CLOUDRON_APP_DOMAIN:-localhost}" + base_url: "https://${CLOUDRON_APP_DOMAIN:-localhost}" EOF chmod 600 "$MUSEUM_CONFIG" log "INFO" "Created Museum configuration at ${MUSEUM_CONFIG}" @@ -243,23 +249,8 @@ fi # =============================================== log "INFO" "Web applications are pre-built and available in /app/web/" -# Fix API endpoint configuration in built JavaScript files -log "INFO" "Updating API endpoint configuration in web apps" -ACTUAL_ENDPOINT="https://${CLOUDRON_APP_DOMAIN}/api" -log "INFO" "Setting API endpoint to: $ACTUAL_ENDPOINT" - -# Replace placeholder endpoint in all JavaScript files -for webapp in photos accounts auth cast; do - WEB_DIR="/app/web/${webapp}" - if [ -d "$WEB_DIR" ]; then - log "INFO" "Processing ${webapp} app" - # Find and replace the placeholder endpoint in all JS files - find "$WEB_DIR" -name "*.js" -type f -exec sed -i "s|https://example.com/api|${ACTUAL_ENDPOINT}|g" {} \; - log "INFO" "Updated endpoint configuration for ${webapp}" - else - log "WARN" "Web directory not found for ${webapp}" - fi -done +# Web apps are built with relative API endpoint (/api) so no runtime replacement needed +log "INFO" "Web apps use relative API endpoint (/api) - Caddy will proxy to Museum server" # =============================================== # Node.js Placeholder Server @@ -389,7 +380,7 @@ const apiHandlers = { token: 'placeholder-jwt-token-' + Date.now(), user: { id: 1, - email: 'placeholder@example.com', + email: 'placeholder@' + (process.env.CLOUDRON_APP_DOMAIN || 'localhost'), name: 'Placeholder User' } })); @@ -418,7 +409,7 @@ const apiHandlers = { token: 'placeholder-jwt-token-' + Date.now(), user: { id: 1, - email: 'placeholder@example.com', + email: 'placeholder@' + (process.env.CLOUDRON_APP_DOMAIN || 'localhost'), name: 'New User' } })); @@ -669,10 +660,14 @@ cat > "$CADDY_CONFIG" << EOF } } - # Health check endpoint + # Health check endpoints handle /health { reverse_proxy localhost:8080 } + + handle /ping { + reverse_proxy localhost:8080 + } # Static files for Next.js assets from all apps handle /_next/* { @@ -773,10 +768,10 @@ cat > /app/data/SETUP-INSTRUCTIONS.md << EOF The following web applications are available: -- Photos: https://${CLOUDRON_APP_FQDN}/photos/ -- Accounts: https://${CLOUDRON_APP_FQDN}/accounts/ -- Auth: https://${CLOUDRON_APP_FQDN}/auth/ -- Cast: https://${CLOUDRON_APP_FQDN}/cast/ +- Photos: https://${CLOUDRON_APP_DOMAIN}/photos/ +- Accounts: https://${CLOUDRON_APP_DOMAIN}/accounts/ +- Auth: https://${CLOUDRON_APP_DOMAIN}/auth/ +- Cast: https://${CLOUDRON_APP_DOMAIN}/cast/ ## Support