-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
43 lines (37 loc) · 1 KB
/
Copy pathconfig.php
File metadata and controls
43 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
// Deteksi environment berdasarkan hostname
$hostname = $_SERVER['HTTP_HOST'] ?? 'localhost';
$isProduction = ($hostname === 'trainhub.web.id' || $hostname === 'www.trainhub.web.id');
// Set base path
if ($isProduction) {
define('BASE_PATH', '');
} else {
define('BASE_PATH', '/trainhub');
}
// Konfigurasi URL API
if ($isProduction) {
// API Production (Hugging Face Space)
define('API_URL', 'https://samsas-trainhub.hf.space');
} else {
// API Development Lokal
define('API_URL', 'http://127.0.0.1:8000');
}
function url($path)
{
// Pastiin path dimulai dengan /
if (substr($path, 0, 1) !== '/') {
$path = '/' . $path;
}
return BASE_PATH . $path;
}
function asset($path)
{
if (substr($path, 0, 1) !== '/') {
$path = '/' . $path;
}
// Cuma tambahin version query string buat file CSS/JS biar ga break URL API
if (preg_match('/\.(css|js)$/i', $path)) {
return BASE_PATH . $path . '?v=' . time();
}
return BASE_PATH . $path;
}