fix(api): Hardcode API URL for Android and add error toast
This commit is contained in:
parent
3151691fac
commit
6607315658
4 changed files with 6 additions and 6 deletions
|
|
@ -3,9 +3,8 @@
|
||||||
* Handles all communication with the backend
|
* Handles all communication with the backend
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const API_BASE = window.location.origin.includes('localhost') || window.location.origin.includes('127.0.0.1')
|
// Hardcode API_BASE to ensure Android App works correctly
|
||||||
? '/api'
|
const API_BASE = 'https://nf.khoavo.myds.me/api';
|
||||||
: 'https://nf.khoavo.myds.me/api';
|
|
||||||
// In production, this should NOT be hardcoded if possible, or obfuscated.
|
// In production, this should NOT be hardcoded if possible, or obfuscated.
|
||||||
// Simple obfuscation for the secret key (should be improved in production)
|
// 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];
|
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];
|
||||||
|
|
|
||||||
|
|
@ -2314,6 +2314,7 @@ async function renderCategoryView(viewType) {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error rendering category view:', error);
|
console.error('Error rendering category view:', error);
|
||||||
|
showToast('Connection failed: ' + error.message, 'error');
|
||||||
elements.videoGrid.innerHTML = `
|
elements.videoGrid.innerHTML = `
|
||||||
<div class="flex flex-col items-center justify-center py-20 text-gray-400">
|
<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>
|
<span class="material-symbols-outlined text-6xl mb-4 opacity-30">error</span>
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,8 @@
|
||||||
* Handles all communication with the backend
|
* Handles all communication with the backend
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const API_BASE = window.location.origin.includes('localhost') || window.location.origin.includes('127.0.0.1')
|
// Hardcode API_BASE to ensure Android App works correctly
|
||||||
? '/api'
|
const API_BASE = 'https://nf.khoavo.myds.me/api';
|
||||||
: 'https://nf.khoavo.myds.me/api';
|
|
||||||
// In production, this should NOT be hardcoded if possible, or obfuscated.
|
// In production, this should NOT be hardcoded if possible, or obfuscated.
|
||||||
// Simple obfuscation for the secret key (should be improved in production)
|
// 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];
|
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];
|
||||||
|
|
|
||||||
|
|
@ -2314,6 +2314,7 @@ async function renderCategoryView(viewType) {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error rendering category view:', error);
|
console.error('Error rendering category view:', error);
|
||||||
|
showToast('Connection failed: ' + error.message, 'error');
|
||||||
elements.videoGrid.innerHTML = `
|
elements.videoGrid.innerHTML = `
|
||||||
<div class="flex flex-col items-center justify-center py-20 text-gray-400">
|
<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>
|
<span class="material-symbols-outlined text-6xl mb-4 opacity-30">error</span>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue