diff --git a/public/_redirects b/public/_redirects index fbc9778..00a62d2 100644 --- a/public/_redirects +++ b/public/_redirects @@ -1,10 +1,5 @@ -# Netlify redirects file -# To proxy API requests through Netlify (bypassing mixed content & CORS), -# replace YOUR_BACKEND_URL with your Termux backend URL (e.g., Cloudflare Tunnel / ngrok URL): -# /files https://YOUR_BACKEND_URL/files 200 -# /upload https://YOUR_BACKEND_URL/upload 200 -# /uploads/* https://YOUR_BACKEND_URL/uploads/:splat 200 -# /delete/* https://YOUR_BACKEND_URL/delete/:splat 200 - -# SPA fallback rule -/* /index.html 200 +/files https://pope-prev-fresh-manufacturer.trycloudflare.com/files 200 +/upload https://pope-prev-fresh-manufacturer.trycloudflare.com/upload 200 +/uploads/* https://pope-prev-fresh-manufacturer.trycloudflare.com/uploads/:splat 200 +/delete/* https://pope-prev-fresh-manufacturer.trycloudflare.com/delete/:splat 200 +/* /index.html 200 diff --git a/public/js/app.js b/public/js/app.js index ef1bccb..f8f9659 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -18,12 +18,14 @@ let selectedFiles = []; // API Base configuration for remote frontend (Netlify) or local hosting + const DEFAULT_REMOTE_API = 'https://pope-prev-fresh-manufacturer.trycloudflare.com'; const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('api')) { const customApi = urlParams.get('api').replace(/\/+$/, ''); localStorage.setItem('katdrop_api', customApi); } - const API_BASE = window.KATDROP_API || localStorage.getItem('katdrop_api') || ''; + const isLocalOrigin = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.hostname.startsWith('192.168.'); + const API_BASE = window.KATDROP_API || localStorage.getItem('katdrop_api') || (isLocalOrigin ? '' : DEFAULT_REMOTE_API); // Toast let toastTimeout;