fix(api): Hardcode API URL for Android and add error toast

This commit is contained in:
Khoa.vo 2025-12-24 16:22:44 +07:00
parent 3151691fac
commit 6607315658
4 changed files with 6 additions and 6 deletions

View file

@ -3,9 +3,8 @@
* Handles all communication with the backend
*/
const API_BASE = window.location.origin.includes('localhost') || window.location.origin.includes('127.0.0.1')
? '/api'
: 'https://nf.khoavo.myds.me/api';
// Hardcode API_BASE to ensure Android App works correctly
const API_BASE = 'https://nf.khoavo.myds.me/api';
// In production, this should NOT be hardcoded if possible, or obfuscated.
// Simple obfuscation for the secret key (should be improved in production)
const _s = [121, 111, 117, 114, 45, 115, 117, 112, 101, 114, 45, 115, 101, 99, 114, 101, 116, 45, 107, 101, 121, 45, 99, 104, 97, 110, 103, 101, 45, 116, 104, 105, 115];

View file

@ -2314,6 +2314,7 @@ async function renderCategoryView(viewType) {
}
} catch (error) {
console.error('Error rendering category view:', error);
showToast('Connection failed: ' + error.message, 'error');
elements.videoGrid.innerHTML = `
<div class="flex flex-col items-center justify-center py-20 text-gray-400">
<span class="material-symbols-outlined text-6xl mb-4 opacity-30">error</span>

View file

@ -3,9 +3,8 @@
* Handles all communication with the backend
*/
const API_BASE = window.location.origin.includes('localhost') || window.location.origin.includes('127.0.0.1')
? '/api'
: 'https://nf.khoavo.myds.me/api';
// Hardcode API_BASE to ensure Android App works correctly
const API_BASE = 'https://nf.khoavo.myds.me/api';
// In production, this should NOT be hardcoded if possible, or obfuscated.
// Simple obfuscation for the secret key (should be improved in production)
const _s = [121, 111, 117, 114, 45, 115, 117, 112, 101, 114, 45, 115, 101, 99, 114, 101, 116, 45, 107, 101, 121, 45, 99, 104, 97, 110, 103, 101, 45, 116, 104, 105, 115];

View file

@ -2314,6 +2314,7 @@ async function renderCategoryView(viewType) {
}
} catch (error) {
console.error('Error rendering category view:', error);
showToast('Connection failed: ' + error.message, 'error');
elements.videoGrid.innerHTML = `
<div class="flex flex-col items-center justify-center py-20 text-gray-400">
<span class="material-symbols-outlined text-6xl mb-4 opacity-30">error</span>