Fix API endpoint configuration and domain references

- 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 <noreply@anthropic.com>
This commit is contained in:
Andreas Dueren
2025-08-01 13:46:17 -06:00
parent da50bf4773
commit 8fbf29fc45
3 changed files with 26 additions and 31 deletions

View File

@@ -7,7 +7,7 @@
"contactEmail": "contact@ente.io", "contactEmail": "contact@ente.io",
"tagline": "Open Source End-to-End Encrypted Photos & Authentication", "tagline": "Open Source End-to-End Encrypted Photos & Authentication",
"upstreamVersion": "1.0.0", "upstreamVersion": "1.0.0",
"version": "0.1.62", "version": "0.1.63",
"healthCheckPath": "/ping", "healthCheckPath": "/ping",
"httpPort": 3080, "httpPort": 3080,
"memoryLimit": 1073741824, "memoryLimit": 1073741824,

View File

@@ -28,10 +28,10 @@ RUN apt-get update && apt-get install -y git && \
RUN corepack enable RUN corepack enable
# Set environment variables for web app build # Set environment variables for web app build
# Set the API endpoint to use current origin - this will work at runtime # Use relative API endpoint so it works with any domain
ENV NEXT_PUBLIC_ENTE_ENDPOINT="https://example.com/api" ENV NEXT_PUBLIC_ENTE_ENDPOINT="/api"
# Add a note for clarity # 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 # Debugging the repository structure
RUN find . -type d -maxdepth 3 | sort RUN find . -type d -maxdepth 3 | sort

View File

@@ -136,13 +136,19 @@ email:
port: ${CLOUDRON_MAIL_SMTP_PORT:-25} port: ${CLOUDRON_MAIL_SMTP_PORT:-25}
username: "${CLOUDRON_MAIL_SMTP_USERNAME:-}" username: "${CLOUDRON_MAIL_SMTP_USERNAME:-}"
password: "${CLOUDRON_MAIL_SMTP_PASSWORD:-}" 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 configuration for passkey support
webauthn: webauthn:
rpid: "${CLOUDRON_APP_FQDN:-localhost}" rpid: "${CLOUDRON_APP_DOMAIN:-localhost}"
rporigins: 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 EOF
chmod 600 "$MUSEUM_CONFIG" chmod 600 "$MUSEUM_CONFIG"
log "INFO" "Created Museum configuration at ${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/" log "INFO" "Web applications are pre-built and available in /app/web/"
# Fix API endpoint configuration in built JavaScript files # Web apps are built with relative API endpoint (/api) so no runtime replacement needed
log "INFO" "Updating API endpoint configuration in web apps" log "INFO" "Web apps use relative API endpoint (/api) - Caddy will proxy to Museum server"
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
# =============================================== # ===============================================
# Node.js Placeholder Server # Node.js Placeholder Server
@@ -389,7 +380,7 @@ const apiHandlers = {
token: 'placeholder-jwt-token-' + Date.now(), token: 'placeholder-jwt-token-' + Date.now(),
user: { user: {
id: 1, id: 1,
email: 'placeholder@example.com', email: 'placeholder@' + (process.env.CLOUDRON_APP_DOMAIN || 'localhost'),
name: 'Placeholder User' name: 'Placeholder User'
} }
})); }));
@@ -418,7 +409,7 @@ const apiHandlers = {
token: 'placeholder-jwt-token-' + Date.now(), token: 'placeholder-jwt-token-' + Date.now(),
user: { user: {
id: 1, id: 1,
email: 'placeholder@example.com', email: 'placeholder@' + (process.env.CLOUDRON_APP_DOMAIN || 'localhost'),
name: 'New User' name: 'New User'
} }
})); }));
@@ -669,10 +660,14 @@ cat > "$CADDY_CONFIG" << EOF
} }
} }
# Health check endpoint # Health check endpoints
handle /health { handle /health {
reverse_proxy localhost:8080 reverse_proxy localhost:8080
} }
handle /ping {
reverse_proxy localhost:8080
}
# Static files for Next.js assets from all apps # Static files for Next.js assets from all apps
handle /_next/* { handle /_next/* {
@@ -773,10 +768,10 @@ cat > /app/data/SETUP-INSTRUCTIONS.md << EOF
The following web applications are available: The following web applications are available:
- Photos: https://${CLOUDRON_APP_FQDN}/photos/ - Photos: https://${CLOUDRON_APP_DOMAIN}/photos/
- Accounts: https://${CLOUDRON_APP_FQDN}/accounts/ - Accounts: https://${CLOUDRON_APP_DOMAIN}/accounts/
- Auth: https://${CLOUDRON_APP_FQDN}/auth/ - Auth: https://${CLOUDRON_APP_DOMAIN}/auth/
- Cast: https://${CLOUDRON_APP_FQDN}/cast/ - Cast: https://${CLOUDRON_APP_DOMAIN}/cast/
## Support ## Support