Expose PocketBase URL to client-side for OIDC auth
Some checks failed
Deploy / deploy (push) Failing after 6m37s
Some checks failed
Deploy / deploy (push) Failing after 6m37s
POCKETBASE_URL was only available server-side, causing the login page to fall back to localhost:8090 in the browser. Renamed to NEXT_PUBLIC_POCKETBASE_URL so Next.js bundles it into client code. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ APP_URL=https://phaseflow.yourdomain.com
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# PocketBase
|
# PocketBase
|
||||||
POCKETBASE_URL=http://localhost:8090
|
NEXT_PUBLIC_POCKETBASE_URL=http://localhost:8090
|
||||||
|
|
||||||
# Email (Resend)
|
# Email (Resend)
|
||||||
RESEND_API_KEY=re_xxxxxxxxxxxx
|
RESEND_API_KEY=re_xxxxxxxxxxxx
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Run these after implementing to get immediate feedback:
|
|||||||
|
|
||||||
## Operational Notes
|
## Operational Notes
|
||||||
|
|
||||||
- Database: PocketBase at `POCKETBASE_URL` env var
|
- Database: PocketBase at `NEXT_PUBLIC_POCKETBASE_URL` env var
|
||||||
- Garmin tokens encrypted with AES-256 using `ENCRYPTION_KEY` (32 chars)
|
- Garmin tokens encrypted with AES-256 using `ENCRYPTION_KEY` (32 chars)
|
||||||
- Path aliases: `@/*` maps to `./src/*`
|
- Path aliases: `@/*` maps to `./src/*`
|
||||||
- Pre-commit hooks: Biome lint + Vitest tests via Lefthook
|
- Pre-commit hooks: Biome lint + Vitest tests via Lefthook
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ let
|
|||||||
export RESEND_API_KEY="re_build_placeholder"
|
export RESEND_API_KEY="re_build_placeholder"
|
||||||
export ENCRYPTION_KEY="build_placeholder_32_chars_long!"
|
export ENCRYPTION_KEY="build_placeholder_32_chars_long!"
|
||||||
export CRON_SECRET="build_placeholder_secret"
|
export CRON_SECRET="build_placeholder_secret"
|
||||||
export POCKETBASE_URL="http://localhost:8090"
|
export NEXT_PUBLIC_POCKETBASE_URL="http://localhost:8090"
|
||||||
export APP_URL="https://phaseflow.v.paler.net"
|
export APP_URL="https://phaseflow.v.paler.net"
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
|||||||
4
spec.md
4
spec.md
@@ -645,7 +645,7 @@ APP_URL=https://phaseflow.yourdomain.com
|
|||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# PocketBase
|
# PocketBase
|
||||||
POCKETBASE_URL=http://localhost:8090
|
NEXT_PUBLIC_POCKETBASE_URL=http://localhost:8090
|
||||||
|
|
||||||
# Email (Resend)
|
# Email (Resend)
|
||||||
RESEND_API_KEY=xxx
|
RESEND_API_KEY=xxx
|
||||||
@@ -700,7 +700,7 @@ job "phaseflow" {
|
|||||||
data = <<EOF
|
data = <<EOF
|
||||||
{{ with nomadVar "nomad/jobs/phaseflow" }}
|
{{ with nomadVar "nomad/jobs/phaseflow" }}
|
||||||
APP_URL={{ .app_url }}
|
APP_URL={{ .app_url }}
|
||||||
POCKETBASE_URL={{ .pocketbase_url }}
|
NEXT_PUBLIC_POCKETBASE_URL={{ .pocketbase_url }}
|
||||||
RESEND_API_KEY={{ .resend_key }}
|
RESEND_API_KEY={{ .resend_key }}
|
||||||
ENCRYPTION_KEY={{ .encryption_key }}
|
ENCRYPTION_KEY={{ .encryption_key }}
|
||||||
CRON_SECRET={{ .cron_secret }}
|
CRON_SECRET={{ .cron_secret }}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ When I access PhaseFlow, I want to securely log in with my identity provider, so
|
|||||||
Using PocketBase for authentication and data storage, with OIDC (Pocket-ID) as the primary identity provider.
|
Using PocketBase for authentication and data storage, with OIDC (Pocket-ID) as the primary identity provider.
|
||||||
|
|
||||||
**Connection:**
|
**Connection:**
|
||||||
- `POCKETBASE_URL` environment variable
|
- `NEXT_PUBLIC_POCKETBASE_URL` environment variable
|
||||||
- `src/lib/pocketbase.ts` initializes client
|
- `src/lib/pocketbase.ts` initializes client
|
||||||
|
|
||||||
## Login Flow
|
## Login Flow
|
||||||
@@ -73,7 +73,7 @@ All routes except `/login` require authentication.
|
|||||||
|
|
||||||
API routes access current user via:
|
API routes access current user via:
|
||||||
```typescript
|
```typescript
|
||||||
const pb = new PocketBase(process.env.POCKETBASE_URL);
|
const pb = new PocketBase(process.env.NEXT_PUBLIC_POCKETBASE_URL);
|
||||||
// Auth token from request cookies
|
// Auth token from request cookies
|
||||||
const user = pb.authStore.model;
|
const user = pb.authStore.model;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import PocketBase, { type RecordModel } from "pocketbase";
|
|||||||
|
|
||||||
import type { OverrideType, User } from "@/types";
|
import type { OverrideType, User } from "@/types";
|
||||||
|
|
||||||
const POCKETBASE_URL = process.env.POCKETBASE_URL || "http://localhost:8090";
|
const 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