From a9a0cf3ac9718db1fc53cc0fafc7c4882d1232e4 Mon Sep 17 00:00:00 2001 From: oiupoyt Date: Sat, 12 Sep 2026 09:59:08 +0530 Subject: [PATCH] feat: configure Cloudflare Tunnel backend URL for seamless Netlify frontend connection --- public/_redirects | 15 +++++---------- public/js/app.js | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-) 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;