From 6e73b7aee77bf7ac7e2abf22cfc02e2b8fc67762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C6=B0=C6=A1ng=20C=E1=BA=A7m?= Date: Sun, 25 Jan 2026 11:42:20 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20S=E1=BB=ADa=20l=E1=BB=97i=20QR=20Code=20?= =?UTF-8?q?URL=20(support=20custom=20public=20URL=20via=20ENV)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 ++ docs/UNRAID_UPDATE.md | 1 + src/app/items/[id]/qr/page.tsx | 1 + src/components/printing/QrCard.tsx | 9 +++++++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d11dea4..a3cf27d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: environment: # Database Connection (SQLite file in volume) - DATABASE_URL=file:/app/db/prod.db + # Public URL for QR Codes (Thay đổi thành domain thực tế của bạn, VD: https://my-nas.com) + - NEXT_PUBLIC_APP_URL=http://localhost:3000 # Production Mode - NODE_ENV=production # Disable Secure Cookie for HTTP (Self-hosted) diff --git a/docs/UNRAID_UPDATE.md b/docs/UNRAID_UPDATE.md index 0891f5a..ff78078 100644 --- a/docs/UNRAID_UPDATE.md +++ b/docs/UNRAID_UPDATE.md @@ -10,6 +10,7 @@ Hãy thêm biến sau vào cấu hình container của bạn (Edit Container): |-----|-------|-------| | `PRISMA_SQLITE_WAL` | `true` | **Quan trọng**: Giúp app chạy nhanh hơn và tránh lỗi lock database | | `DATABASE_URL` | `file:/app/db/prod.db` | Bắt buộc để dữ liệu không bị mất | +| `NEXT_PUBLIC_APP_URL` | `https://your-domain.com` | **Cần thiết cho QR**: Nhập địa chỉ Cloudflare Tunnel/Public URL của bạn để mã QR dẫn đúng link | ## Cách cập nhật (Update) an toàn diff --git a/src/app/items/[id]/qr/page.tsx b/src/app/items/[id]/qr/page.tsx index 863b37c..f00b405 100644 --- a/src/app/items/[id]/qr/page.tsx +++ b/src/app/items/[id]/qr/page.tsx @@ -13,6 +13,7 @@ export default async function ItemQRPage({ params }: { params: Promise<{ id: str notFound(); } + // URL for QR: Prefer Env Var (Public URL), fallback to localhost implies internal usage mostly const appUrl = process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000"; const qrValue = `${appUrl}/items/${item.id}`; diff --git a/src/components/printing/QrCard.tsx b/src/components/printing/QrCard.tsx index 81b28d8..c948103 100644 --- a/src/components/printing/QrCard.tsx +++ b/src/components/printing/QrCard.tsx @@ -49,7 +49,12 @@ export const QrCard = ({ item, simpleMode = false }: { item: ItemForPrint, simpl
- +
@@ -83,7 +88,7 @@ export const QrCard = ({ item, simpleMode = false }: { item: ItemForPrint, simpl