Add HTTPS image proxy and auto-fix for mixed content
This commit is contained in:
@@ -252,6 +252,45 @@
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- HTTPS Image Proxy for Supabase Storage -->
|
||||
<script>
|
||||
(function() {
|
||||
function proxySupabaseImages() {
|
||||
// Find all images with Supabase storage URLs
|
||||
document.querySelectorAll('img[src*="/storage/v1/object/public/"]').forEach(img => {
|
||||
const originalSrc = img.src;
|
||||
|
||||
// Only proxy HTTP URLs (HTTPS is fine)
|
||||
if (originalSrc.startsWith('http://')) {
|
||||
// Extract bucket and path from URL
|
||||
// Format: http://.../storage/v1/object/public/{bucket}/{path}
|
||||
const match = originalSrc.match(/\/storage\/v1\/object\/public\/([^\/]+)\/(.+)/);
|
||||
|
||||
if (match) {
|
||||
const bucket = match[1];
|
||||
const path = match[2];
|
||||
const proxyUrl = `/proxy/image/${bucket}/${path}`;
|
||||
|
||||
img.src = proxyUrl;
|
||||
console.log('Proxied image:', originalSrc, '->', proxyUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Run on page load
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', proxySupabaseImages);
|
||||
} else {
|
||||
proxySupabaseImages();
|
||||
}
|
||||
|
||||
// Also run after dynamic content loads (e.g., AJAX)
|
||||
const observer = new MutationObserver(proxySupabaseImages);
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -109,6 +109,34 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- HTTPS Image Proxy for Supabase Storage -->
|
||||
<script>
|
||||
(function() {
|
||||
function proxySupabaseImages() {
|
||||
document.querySelectorAll('img[src*="/storage/v1/object/public/"]').forEach(img => {
|
||||
const originalSrc = img.src;
|
||||
if (originalSrc.startsWith('http://')) {
|
||||
const match = originalSrc.match(/\/storage\/v1\/object\/public\/([^\/]+)\/(.+)/);
|
||||
if (match) {
|
||||
const bucket = match[1];
|
||||
const path = match[2];
|
||||
img.src = `/proxy/image/${bucket}/${path}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', proxySupabaseImages);
|
||||
} else {
|
||||
proxySupabaseImages();
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(proxySupabaseImages);
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user