Separate server-side and client-side PocketBase URLs
All checks were successful
Deploy / deploy (push) Successful in 2m29s
All checks were successful
Deploy / deploy (push) Successful in 2m29s
Server-side code (health checks, API routes) needs to use internal sidecar URL (POCKETBASE_URL at runtime), while client-side needs public URL (NEXT_PUBLIC_POCKETBASE_URL baked at build time). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,9 @@ APP_URL=https://phaseflow.yourdomain.com
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# PocketBase
|
# PocketBase
|
||||||
|
# POCKETBASE_URL is for server-side (API routes, health checks) - set at runtime
|
||||||
|
# NEXT_PUBLIC_POCKETBASE_URL is for client-side (browser) - baked at build time
|
||||||
|
POCKETBASE_URL=http://localhost:8090
|
||||||
NEXT_PUBLIC_POCKETBASE_URL=http://localhost:8090
|
NEXT_PUBLIC_POCKETBASE_URL=http://localhost:8090
|
||||||
|
|
||||||
# Email (Resend)
|
# Email (Resend)
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ import PocketBase, { type RecordModel } from "pocketbase";
|
|||||||
|
|
||||||
import type { OverrideType, User } from "@/types";
|
import type { OverrideType, User } from "@/types";
|
||||||
|
|
||||||
|
// Client-side uses NEXT_PUBLIC_POCKETBASE_URL (baked at build time)
|
||||||
|
// Server-side uses POCKETBASE_URL (runtime) for internal communication, falls back to NEXT_PUBLIC_
|
||||||
const POCKETBASE_URL =
|
const POCKETBASE_URL =
|
||||||
process.env.NEXT_PUBLIC_POCKETBASE_URL || "http://localhost:8090";
|
process.env.POCKETBASE_URL ||
|
||||||
|
process.env.NEXT_PUBLIC_POCKETBASE_URL ||
|
||||||
|
"http://localhost:8090";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton PocketBase client for client-side usage.
|
* Singleton PocketBase client for client-side usage.
|
||||||
|
|||||||
Reference in New Issue
Block a user