// basePath (/docedit/note) — ค่าจาก next.config.mjs (inline ตอน build ผ่าน env) // ใช้กับ URL ฝั่ง browser ที่ Next ไม่เติม basePath ให้เอง: fetch/EventSource/ // plain /workerSrc/img src — ต่างจาก /router/redirect ของ next // ที่เติมให้อัตโนมัติ (pdfUrl ใน DB เก็บ path ไม่รวม basePath เติมตอนใช้เท่านั้น) export function withBasePath(path: string): string { // absolute http(s) ผ่านไปเฉย ๆ (N8: pdf_url เก็บ URL รีโมตได้ — ห้าม prefix ทับ) if (/^https?:\/\//i.test(path)) return path; return `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}${path}`; }