feat: configure Cloudflare Tunnel backend URL for seamless Netlify frontend connection
This commit is contained in:
parent
55015d94d1
commit
a9a0cf3ac9
2 changed files with 8 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue