pocketbase url was wrong
This commit is contained in:
@@ -204,10 +204,19 @@ export const FALLBACK_FOOD: FoodItem[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const getPbUrl = () => {
|
const getPbUrl = () => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof import.meta !== 'undefined' && import.meta.env?.VITE_PB_URL) {
|
||||||
return `${window.location.protocol}//${window.location.hostname}:8090`;
|
return import.meta.env.VITE_PB_URL;
|
||||||
}
|
}
|
||||||
return 'http://127.0.0.1:8090';
|
if (typeof window !== 'undefined') {
|
||||||
|
// In local development, PocketBase runs on dedicated port 8090
|
||||||
|
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
|
||||||
|
return `${window.location.protocol}//${window.location.hostname}:8090`;
|
||||||
|
}
|
||||||
|
// In production, Caddy reverse-proxies /api/* to PocketBase on port 443 (same origin)
|
||||||
|
return window.location.origin;
|
||||||
|
}
|
||||||
|
// Server-side (SSR) inside Docker container
|
||||||
|
return process.env.PB_URL || 'http://127.0.0.1:8090';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pb = new PocketBase(getPbUrl());
|
export const pb = new PocketBase(getPbUrl());
|
||||||
|
|||||||
Reference in New Issue
Block a user