Skip to content

Commit 98bbc5d

Browse files
CopilotSnozxyx
andcommitted
Fix CORS handling for webOS app API integration - enables both development and production environments
Co-authored-by: Snozxyx <150821778+Snozxyx@users.noreply.github.com>
1 parent 4e205c3 commit 98bbc5d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tatakai-webos-app/js/api-client.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,26 @@
44
*/
55
class TatakaiAnimeAPI {
66
static BASE_URL = 'https://aniwatch-api-taupe-eight.vercel.app/api/v2/hianime';
7+
static LOCAL_PROXY = 'http://localhost:3001/api';
78

89
/**
910
* Generic fetch wrapper for API calls
1011
*/
1112
static async fetchAPI(endpoint, options = {}) {
1213
try {
13-
const url = `${this.BASE_URL}${endpoint}`;
14+
let url = `${this.BASE_URL}${endpoint}`;
15+
16+
// In development/browser environment, use local proxy for CORS
17+
// In actual webOS environment, direct calls should work fine
18+
if (typeof window !== 'undefined' &&
19+
(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) {
20+
url = `${this.LOCAL_PROXY}${endpoint}`;
21+
}
22+
1423
console.log('Fetching:', url);
1524

1625
const response = await fetch(url, {
26+
mode: 'cors',
1727
headers: {
1828
'Accept': 'application/json',
1929
'User-Agent': 'Mozilla/5.0 (Web0S; Linux; SmartTV) Tatakai/1.0.0',

0 commit comments

Comments
 (0)