Updates to deployment.
This commit is contained in:
@ -1,5 +1,37 @@
|
||||
export const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000'
|
||||
export const WS_URL = import.meta.env.VITE_WS_URL || 'ws://localhost:8000'
|
||||
// Auto-detect API URL based on environment
|
||||
const getApiUrl = () => {
|
||||
// If explicitly set via env var, use that
|
||||
if (import.meta.env.VITE_API_URL) {
|
||||
return import.meta.env.VITE_API_URL
|
||||
}
|
||||
|
||||
// In production (not localhost), use the current origin
|
||||
if (typeof window !== 'undefined' && !window.location.hostname.includes('localhost')) {
|
||||
return window.location.origin
|
||||
}
|
||||
|
||||
// Default for local development
|
||||
return 'http://localhost:8000'
|
||||
}
|
||||
|
||||
const getWsUrl = () => {
|
||||
// If explicitly set via env var, use that
|
||||
if (import.meta.env.VITE_WS_URL) {
|
||||
return import.meta.env.VITE_WS_URL
|
||||
}
|
||||
|
||||
// In production (not localhost), use the current origin with ws/wss protocol
|
||||
if (typeof window !== 'undefined' && !window.location.hostname.includes('localhost')) {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
|
||||
return `${protocol}//${window.location.host}`
|
||||
}
|
||||
|
||||
// Default for local development
|
||||
return 'ws://localhost:8000'
|
||||
}
|
||||
|
||||
export const API_URL = getApiUrl()
|
||||
export const WS_URL = getWsUrl()
|
||||
|
||||
export const BET_CATEGORIES = {
|
||||
sports: 'Sports',
|
||||
|
||||
Reference in New Issue
Block a user