Skip to content

Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.

fix(v0.29.1): admin version 'unknown' on the VPS + build identity

Ashiq Hussain Mirbfe8583e0a10
diff --git a/next.config.ts b/next.config.ts
index af4ed16..b139afa 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,4 +1,6 @@
import type { NextConfig } from "next";
+import { execSync } from "node:child_process";
+import { readFileSync } from "node:fs";
// ─────────────────────────────────────────────────────────────────
// Security headers + CSP baseline (v0.12.1, roadmap H3 — see
@@ -61,7 +63,25 @@ const securityHeaders = [
{ key: "Content-Security-Policy-Report-Only", value: CSP_REPORT_ONLY },
];
+// v0.29.1: build identity, baked in at build time. The VPS runs the
+// standalone server as plain `node` — npm_package_version is absent
+// there, which is why the admin panel's version showed "unknown".
+// Next inlines these `env` values into both server and client bundles.
+const pkgVersion = (() => {
+ try { return JSON.parse(readFileSync("package.json", "utf8")).version ?? "dev"; }
+ catch { return "dev"; }
+})();
+const buildCommit = (() => {
+ try { return execSync("git rev-parse --short HEAD", { stdio: ["ignore", "pipe", "ignore"] }).toString().trim(); }
+ catch { return "nogit"; }
+})();
+const buildTime = new Date().toISOString();
const nextConfig: NextConfig = {
+ env: {
+ CANVIX_APP_VERSION: String(pkgVersion),
+ CANVIX_BUILD_COMMIT: buildCommit,
+ CANVIX_BUILD_TIME: buildTime,
+ },
output: "standalone",
async headers() {
return [
diff --git a/package.json b/package.json
index acc2ce5..567f9d2 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
{
"name": "canvix",
- "version": "0.23.2",
+ "version": "0.29.1",
"private": false,
- "description": "Canvix \u2014 free & open-source graphic design tool. A community-built Canva alternative.",
+ "description": "Canvix — free & open-source graphic design tool. A community-built Canva alternative.",
"scripts": {
"dev": "next dev -p 3000 2>&1 | tee dev.log",
"build": "node scripts/build.mjs",
diff --git a/src/app/api/admin/overview/route.ts b/src/app/api/admin/overview/route.ts
index 77aa26d..6cf9c01 100644
--- a/src/app/api/admin/overview/route.ts
+++ b/src/app/api/admin/overview/route.ts
@@ -3,7 +3,7 @@ import { db } from '@/lib/db'
import { requireAdmin, isAdminUser, adminSource } from '@/lib/admin/guard'
import { providersSummary } from '@/lib/ai/provider'
import { fillDays, sumSeries, dayKey, type DayPoint } from '@/lib/admin/series'
-import { APP_VERSION, withLogging } from '@/lib/observability'
+import { APP_VERSION, APP_BUILD_COMMIT, withLogging } from '@/lib/observability'
export const runtime = 'nodejs'
export const dynamic = 'force-dynamic'
@@ -118,6 +118,7 @@ async function __canvix_get(req: NextRequest) {
return NextResponse.json({
version: APP_VERSION,
+ build: APP_BUILD_COMMIT || undefined,
dbLatencyMs,
totals: {
users,
diff --git a/src/app/api/health/route.ts b/src/app/api/health/route.ts
index 4a789e8..420296f 100644
--- a/src/app/api/health/route.ts
+++ b/src/app/api/health/route.ts
@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from 'next/server'
import { db } from '@/lib/db'
import { describeDatabaseUrl } from '@/lib/db-url'
-import { APP_VERSION } from '@/lib/observability'
+import { APP_VERSION, APP_BUILD_COMMIT, APP_BUILD_TIME } from '@/lib/observability'
import { withLogging } from '@/lib/observability'
// GET /api/health — one-shot setup diagnostics.
@@ -155,7 +155,7 @@ async function __canvix_get(req: NextRequest) {
comments: n(comments),
},
db: { latencyMs: dbLatencyMs },
- app: { version: APP_VERSION, uptimeSec: Math.round(process.uptime()) },
+ app: { version: APP_VERSION, commit: APP_BUILD_COMMIT, builtAt: APP_BUILD_TIME, uptimeSec: Math.round(process.uptime()) },
},
{
headers: {
diff --git a/src/components/admin/overview.tsx b/src/components/admin/overview.tsx
index c6fa7db..0ce949a 100644
--- a/src/components/admin/overview.tsx
+++ b/src/components/admin/overview.tsx
@@ -15,6 +15,7 @@ interface AiDayPoint extends DayPoint {
}
interface Overview {
version: string
+ build?: string
dbLatencyMs: number
totals: {
users: number
@@ -190,7 +191,7 @@ export function AdminOverview() {
<Card title="Instance">
<dl className="grid grid-cols-2 gap-x-4 gap-y-2 text-sm">
<dt className="text-muted-foreground">Canvix version</dt>
- <dd className="text-right font-medium tabular-nums">{data.version}</dd>
+ <dd className="text-right font-medium tabular-nums">{data.version}{data.build ? <span className="text-muted-foreground"> · {data.build}</span> : null}</dd>
<dt className="text-muted-foreground">Database latency</dt>
<dd className="text-right font-medium tabular-nums">{data.dbLatencyMs} ms</dd>
<dt className="text-muted-foreground">AI providers</dt>
diff --git a/src/lib/observability.ts b/src/lib/observability.ts
index b1ba986..0c3d97b 100644
--- a/src/lib/observability.ts
+++ b/src/lib/observability.ts
@@ -22,8 +22,17 @@
import type { NextRequest } from 'next/server'
-/** The app version answering requests — from package.json at build time. */
-export const APP_VERSION = process.env.npm_package_version ?? 'unknown'
+/** The app version answering requests. Baked at build time via
+ * next.config `env` (v0.29.1) so the standalone `node` deploy on the
+ * VPS reports a real version — npm_package_version only exists when
+ * npm itself starts the process, which is why the admin panel used
+ * to show "unknown" there. */
+export const APP_VERSION =
+ process.env.CANVIX_APP_VERSION || process.env.npm_package_version || 'unknown'
+/** Short git commit the bundle was built from ('' when unknown). */
+export const APP_BUILD_COMMIT = process.env.CANVIX_BUILD_COMMIT || ''
+/** ISO build timestamp ('' when unknown). */
+export const APP_BUILD_TIME = process.env.CANVIX_BUILD_TIME || ''
export type LogLevel = 'debug' | 'info' | 'warn' | 'error'