ranilmukesh commited on
Commit
712f10d
·
1 Parent(s): dfe09a2

feat: enhance API base URL configuration for local and production environments

Browse files
Files changed (1) hide show
  1. script.js +4 -2
script.js CHANGED
@@ -6,8 +6,10 @@
6
  */
7
 
8
  // API Configuration
9
- // Use specific port 8000 for backend API calls
10
- const API_BASE_URL = window.location.protocol + "//" + window.location.hostname + ":8000";
 
 
11
 
12
  // DOM Elements
13
  const elements = {
 
6
  */
7
 
8
  // API Configuration
9
+ // Smart API Configuration: Use port 8000 locally, but use the current origin for remote (HF/Production)
10
+ const API_BASE_URL = (window.location.hostname === "127.0.0.1" || window.location.hostname === "localhost")
11
+ ? window.location.protocol + "//" + window.location.hostname + ":8000"
12
+ : window.location.origin;
13
 
14
  // DOM Elements
15
  const elements = {