Skip to content

Commit 337c160

Browse files
committed
feat(site): auto-detect environment from hostname
Replace hardcoded environment toggle with runtime hostname detection: - localhost/127.0.0.1 → development (local data) - Any other domain → production (Bunny CDN) - Query param override: ?env=development or ?env=production
1 parent b66d422 commit 337c160

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

site/config.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@
44
*/
55

66
const CONFIG = {
7-
// Current active environment - change this to switch environments
8-
environment: 'development',
9-
// environment: 'production',
7+
// Auto-detect environment based on hostname
8+
// Override with query param: ?env=development or ?env=production
9+
environment: (() => {
10+
const params = new URLSearchParams(window.location.search);
11+
const envOverride = params.get('env');
12+
if (envOverride === 'development' || envOverride === 'production') {
13+
return envOverride;
14+
}
15+
const host = window.location.hostname;
16+
if (host === 'localhost' || host === '127.0.0.1' || host === '') {
17+
return 'development';
18+
}
19+
return 'production';
20+
})(),
1021

1122
// Environment configurations
1223
environments: {

0 commit comments

Comments
 (0)