Implement comprehensive web app API endpoint fix

- Patch origins.ts during Docker build to use window.location.origin + '/api'
- Update version to 0.1.69 to force rebuild
- Add browser compatibility check for server-side rendering
- Fix both API and uploader endpoint redirections

This addresses the root cause where web apps were hardcoded to use
https://api.ente.io instead of the local Museum server.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Your Name
2025-07-25 19:27:11 -06:00
parent c7b9ab18bb
commit 06e0f5075e
5 changed files with 56 additions and 7 deletions

View File

@@ -28,10 +28,20 @@ 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="/api"
# Use relative path so it works with any domain
RUN echo "Building with NEXT_PUBLIC_ENTE_ENDPOINT=/api, will work with any domain via Caddy proxy"
# Instead of using a relative path, patch the origins.ts file to use dynamic origin
RUN echo "Patching origins.ts to use dynamic API endpoint based on current origin"
# Patch the origins.ts file to use relative API endpoint instead of hardcoded ente.io
RUN if [ -f "web/packages/base/origins.ts" ]; then \
echo "Patching origins.ts to use window.location.origin + '/api'"; \
sed -i 's|(await customAPIOrigin()) ?? "https://api.ente.io"|(await customAPIOrigin()) ?? (typeof window !== "undefined" ? window.location.origin + "/api" : "https://api.ente.io")|g' web/packages/base/origins.ts; \
sed -i 's|(await customAPIOrigin()) ?? "https://uploader.ente.io"|(await customAPIOrigin()) ?? (typeof window !== "undefined" ? window.location.origin + "/api" : "https://uploader.ente.io")|g' web/packages/base/origins.ts; \
echo "Patched origins.ts:"; \
cat web/packages/base/origins.ts | head -20; \
else \
echo "origins.ts not found, checking alternative paths"; \
find . -name "origins.ts" -type f; \
fi
# Debugging the repository structure
RUN find . -type d -maxdepth 3 | sort