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:
@@ -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,
|
||||
|
@@ -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
|
||||
|
49
start.sh
49
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,11 +660,15 @@ 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/* {
|
||||
@photosNext path /_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
|
||||
|
||||
|
Reference in New Issue
Block a user