pocketbase url was wrong

This commit is contained in:
2026-09-02 18:22:53 +00:00
parent ee17dda304
commit 486ed14ee9
+12 -3
View File
@@ -204,10 +204,19 @@ export const FALLBACK_FOOD: FoodItem[] = [
];
const getPbUrl = () => {
if (typeof window !== 'undefined') {
return `${window.location.protocol}//${window.location.hostname}:8090`;
if (typeof import.meta !== 'undefined' && import.meta.env?.VITE_PB_URL) {
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());