Skip to content

Commit 351da6c

Browse files
Merge pull request #248 from tswicegood/contrib/tswicegood/dashboard-open-next-cloudflare
[dashboards] open-brain-dashboard-next: add Cloudflare Workers deploy support
2 parents 5d3f6ab + 4795ce7 commit 351da6c

6 files changed

Lines changed: 10131 additions & 4436 deletions

File tree

dashboards/open-brain-dashboard-next/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
node_modules/
22
.next/
33
.vercel/
4+
.open-next/
5+
.wrangler/
46
.env
57
.env.local
68
.env.local.example

dashboards/open-brain-dashboard-next/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ Or connect the folder to Vercel via the dashboard. Set the environment variables
105105
> [!TIP]
106106
> The free Vercel tier is sufficient. The dashboard makes server-side API calls to your Open Brain REST endpoint — there's no heavy compute.
107107
108+
### Step 5 (alternative): Deploy to Cloudflare Workers (optional)
109+
110+
If you're already on Cloudflare for the [`open-brain-rest`](../../integrations/cloudflare-rest-worker/) gateway, you can host the dashboard on the same platform via the [`@opennextjs/cloudflare`](https://opennext.js.org/cloudflare) adapter. The older `@cloudflare/next-on-pages` adapter caps at Next 15.5.x and doesn't support this dashboard's Next 16.
111+
112+
The repo ships the two config files this needs out of the box (`open-next.config.ts` and `wrangler.jsonc`); rename the Worker in `wrangler.jsonc` if you want something other than `ob-dashboard`.
113+
114+
```bash
115+
# 1. Make sure .env has NEXT_PUBLIC_API_URL set — it's read at *build*
116+
# time and baked into the client bundle.
117+
npx opennextjs-cloudflare build
118+
119+
# 2. First-time deploy creates the Worker.
120+
npx opennextjs-cloudflare deploy
121+
122+
# 3. Set SESSION_SECRET as a *runtime* secret on the deployed Worker.
123+
# (NEXT_PUBLIC_API_URL is build-time only, so no Worker secret for it.)
124+
wrangler secret put SESSION_SECRET --name ob-dashboard
125+
```
126+
127+
The dashboard ends up at `https://ob-dashboard.<your-cf-subdomain>.workers.dev`.
128+
129+
> [!TIP]
130+
> `NEXT_PUBLIC_API_URL` is build-time, `SESSION_SECRET` is runtime. If you change the API URL later you have to rebuild and redeploy; rotating the session secret only needs `wrangler secret put`.
131+
108132
## Expected Outcome
109133

110134
When working correctly:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2+
3+
export default defineCloudflareConfig({});

0 commit comments

Comments
 (0)