eCourt-note/app/wordaddin/install-word-addins.ps1/route.ts
2026-10-29 16:15:54 +07:00

17 lines
756 B
TypeScript

import fs from "node:fs";
import path from "node:path";
import { requestOrigin } from "@/utils/request-origin";
// GET /wordaddin/install-word-addin.ps1 — สำหรับติดตั้ง Word add-in
const DEV_ORIGIN = "https://localhost:3000";
const TEMPLATE = path.join(process.cwd(),"app","wordaddin","install-word-addins.ps1", "template.ps1");
export function GET(req: Request): Response {
const template = fs.readFileSync(TEMPLATE, "utf8");
const manifest = template.replaceAll(DEV_ORIGIN, requestOrigin(req));
return new Response(manifest, {
headers: {
"content-type": "text/plain; charset=utf-8",
"Content-Disposition": "attachment; filename=install-word-addins.ps1",
"cache-control": "no-store",
},
});
}