eCourt-note/next.config.mjs
oom 2e951f99f4
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m19s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 5s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 0s
fix worker not found module in build standalone
fix next/link prefetch/call twice(replace with a)
2026-11-04 00:33:07 +07:00

56 lines
3.4 KiB
JavaScript

const basePath = "/docedit";
// prefix ระดับแอปของ judes-note ใน route tree (app/note/**) + statics (public/note/**)
// — basePath /docedit เป็นของกลางแชร์กับแอปพี่น้อง (เช่น wordaddin ในอนาคต)
// URL ปลายทางจึงยังเป็น /docedit/note/… เหมือนเดิมทุกจุด
const appPath = "/note";
/** @type {import('next').NextConfig} */
const nextConfig = {
// สำหรับ Docker (docker/web.Dockerfile) — build แล้วได้ .next/standalone รันด้วย node server.js
output: "standalone",
// serve ใต้ /docedit + route ทั้งหมดอยู่ใต้ app/note/** — <Link>/next/navigation เติม basePath
// ให้เอง แต่ต้องเขียน path รวม /note (เช่น href="/note/annotate") ส่วน fetch/EventSource/
// plain <a href>/workerSrc ต้องผ่าน withBasePath() (utils/base-path.ts — เติม base + /note)
basePath,
// expose ให้โค้ดใช้ (inline ตอน build) — ค่าจริงประกาศที่เดียวที่ไฟล์นี้
env: { NEXT_PUBLIC_BASE_PATH: basePath, NEXT_PUBLIC_APP_PATH: appPath },
// ปิด redirect trailing slash อัตโนมัติของ Next (308 /docedit → /docedit/
// และ /docedit/note/ → /docedit/note) — deploy หลัง IIS แล้ว redirect พวกนี้
// ตีกับ rewrite rule ของ IIS จนกลายเป็น ping-pong loop; ปิดให้หน้า/ไฟล์ทุกอย่าง
// serve ได้ทั้งแบบมี/ไม่มี slash ฝั่ง proxy เป็นคนกำหนดเอง
skipTrailingSlashRedirect: true,
// จับเฉพาะ root ของ host ("/" แท้ ๆ — basePath:false ทำให้ rule นี้ไม่จับ
// /docedit) เผื่อ IIS ส่ง path "/" เข้า process: ส่งตรงไป /docedit/note เลย
// ส่วน /docedit และ /docedit/ จับที่ app/page.tsx แทน (ส่งต่อ query เอง —
// รักษาสัญญาลิงก์ e-Court /docedit/?fileUrl=&fileId=&typeId=)
async redirects() {
return [
{
source: "/",
destination: `${basePath}${appPath}`,
basePath: false, // ป้องกัน basePath ซ้อน (destination เขียนเต็มแล้ว)
permanent: false,
},
];
},
experimental: {
serverComponentsExternalPackages: ['piscina'],
outputFileTracingIncludes: {
// ปรับ Path ฝั่งซ้ายให้ตรงกับ API Route หรือจุดที่เรียกใช้ Piscina
'/api/**/*': [
'node_modules/piscina/**/*',
'node_modules/pizzip/**/*',
'node_modules/@xmldom/xmldom/**/*',
'node_modules/xpath/**/*',
'node_modules/docx-templates/**/*',
'node_modules/jszip/**/*',
'node_modules/setimmediate/**/*',
'node_modules/pako/**/*',
'workers/**/*' // Path ที่เก็บไฟล์ worker.js ของคุณ (ปรับตามจริง)
],
},
}
};
export default nextConfig;