api config: add getImageBaseUrl, fix api path for prod/dev
This commit is contained in:
parent
19a2b9e77f
commit
e9463ae5ba
1 changed files with 22 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Configuration for API adapters
|
||||
*/
|
||||
import { PUBLIC_SIERO_API_URL } from '$env/static/public'
|
||||
import { PUBLIC_SIERO_API_URL, PUBLIC_SIERO_IMG_URL } from '$env/static/public'
|
||||
|
||||
/**
|
||||
* Get the base URL for API requests
|
||||
|
|
@ -11,7 +11,27 @@ export function getApiBaseUrl(): string {
|
|||
const base = PUBLIC_SIERO_API_URL || 'http://localhost:3000'
|
||||
// Production API uses /v1, development uses /api/v1
|
||||
const apiPath = import.meta.env.PROD ? '/v1' : '/api/v1'
|
||||
return `${base}${apiPath}`
|
||||
const url = `${base}${apiPath}`
|
||||
console.log('[API Config]', { base, apiPath, url, isProd: import.meta.env.PROD })
|
||||
return url
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base URL for image assets
|
||||
* Uses AWS S3/CDN URL in production when PUBLIC_SIERO_IMG_URL is set,
|
||||
* otherwise falls back to local /images directory
|
||||
*/
|
||||
export function getImageBaseUrl(): string {
|
||||
// If PUBLIC_SIERO_IMG_URL is set (non-empty), use it
|
||||
// Otherwise use local images (empty string means relative path)
|
||||
return PUBLIC_SIERO_IMG_URL || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're using remote images (AWS S3/CDN)
|
||||
*/
|
||||
export function isUsingRemoteImages(): boolean {
|
||||
return Boolean(PUBLIC_SIERO_IMG_URL)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue