Fix URL construction error by ensuring proper URL formats with protocol prefixes

This commit is contained in:
Andreas Düren 2025-03-18 20:47:23 +01:00
parent 1244467afa
commit f545b8d797

View File

@ -1597,6 +1597,17 @@ window.process = window.process || {};
window.process.env = window.process.env || {};
window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = '${API_ENDPOINT}';
window.process.env.NEXT_PUBLIC_ENTE_PUBLIC_ALBUMS_ENDPOINT = '${CLOUDRON_APP_ORIGIN}/public';
window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}';
window.process.env.REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}';
// Make sure all URLs are properly formatted for URL constructor
if (!window.ENTE_CONFIG.API_URL.startsWith('http')) {
console.log('Adding https:// prefix to API_URL');
window.ENTE_CONFIG.API_URL = window.location.origin + window.ENTE_CONFIG.API_URL;
window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
window.process.env.REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.REACT_APP_ENTE_ENDPOINT;
window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT;
}
console.log('Ente runtime config loaded from runtime-config.js');
console.log('API_URL:', window.ENTE_CONFIG.API_URL);
@ -1679,6 +1690,17 @@ cat > /app/data/caddy/Caddyfile <<EOT
window.process.env = window.process.env || {};
window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = '${API_ENDPOINT}';
window.process.env.NEXT_PUBLIC_ENTE_PUBLIC_ALBUMS_ENDPOINT = '${CLOUDRON_APP_ORIGIN}/public';
window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}';
window.process.env.REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}';
// Make sure all URLs are properly formatted for URL constructor
if (!window.ENTE_CONFIG.API_URL.startsWith('http')) {
console.log('Adding https:// prefix to API_URL');
window.ENTE_CONFIG.API_URL = window.location.origin + window.ENTE_CONFIG.API_URL;
window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
window.process.env.REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.REACT_APP_ENTE_ENDPOINT;
window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT;
}
console.log('Ente config loaded - API_URL:', window.ENTE_CONFIG.API_URL);
console.log('Ente config loaded - PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL);