fronted build js-cookiep

This commit is contained in:
admin
2025-10-05 09:40:55 +07:00
parent 3448594bc5
commit da568bb85f
7 changed files with 26 additions and 7606 deletions

View File

@@ -1,11 +0,0 @@
{
"folders": [
{
"path": "."
},
{
"path": "S:/Documents"
}
],
"settings": {}
}

View File

@@ -1,9 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
},
"exclude": ["node_modules", ".next"]
}

View File

@@ -1,61 +0,0 @@
// frontend/middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
// ให้ตรงกับชื่อคุกกี้ที่ backend เซ็ต
const COOKIE_NAME = "access_token";
// หน้าที่เปิดได้โดยไม่ต้องล็อกอิน (ถ้าต้องการเพิ่มให้ใส่เพิ่มที่นี่)
const PUBLIC_PREFIXES = ["/login", "/register", "/health", "/api/health"];
// const PUBLIC_PATHS = new Set<string>(["/login", "/register", "/health"]);
export function middleware(req: NextRequest) {
const { pathname, search } = req.nextUrl;
// อนุญาตไฟล์สาธารณะและ Static assets
if (
pathname.startsWith("/_next/") ||
pathname.startsWith("/public/") ||
pathname === "/favicon.ico"
) {
return NextResponse.next();
}
// หน้าสาธารณะ: ปล่อยผ่าน
// if (PUBLIC_PATHS.has(pathname)) {
// return NextResponse.next();
// }
// อนุญาตหน้า public
if (PUBLIC_PREFIXES.some((p) => pathname.startsWith(p))) {
return NextResponse.next();
}
// ตรวจ token จาก cookie
const token = req.cookies.get(COOKIE_NAME)?.value;
// ไม่มี token → เด้งไป /login พร้อม next=path เดิม
if (!token) {
const url = req.nextUrl.clone();
url.pathname = "/login";
url.searchParams.set("next", pathname + (search || ""));
return NextResponse.redirect(url);
}
// มี token → ผ่าน
return NextResponse.next();
}
// จำกัดให้ตรวจเฉพาะเส้นทาง protected (ลดโอเวอร์เฮด)
export const config = {
matcher: [
"/dashboard/:path*",
"/drawings/:path*",
"/rfas/:path*",
"/transmittals/:path*",
"/correspondences/:path*",
"/contracts-volumes/:path*",
"/users/:path*",
"/reports/:path*",
"/workflow/:path*",
"/admin/:path*",
],
};

View File

@@ -1,26 +0,0 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
// แนะนำย้ายค่าพวกนี้ไป .env(.local) แล้วใช้ process.env ฝั่งโค้ดแทน
// เก็บไว้ชั่วคราวได้ถ้ายังไม่ทำ .env
env: {
NEXT_PUBLIC_API_BASE: process.env.NEXT_PUBLIC_API_BASE || "http://localhost:8080"
},
images: {
remotePatterns: [
// { protocol: "https", hostname: "lcbp3.np-dms.work" },
],
},
// ลดโอกาส build ล้มเพราะ lint (เฉพาะ production build)
eslint: {
ignoreDuringBuilds: true,
},
// ถ้าไม่มี TypeScript ไม่ต้องใส่ส่วนนี้
// typescript: { ignoreBuildErrors: true },
};
module.exports = nextConfig;

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,7 @@
"clsx": "^2.1.1", "clsx": "^2.1.1",
"framer-motion": "^11.2.10", "framer-motion": "^11.2.10",
"jsonwebtoken": "^9.0.2", "jsonwebtoken": "^9.0.2",
"js-cookie": "^3.0.5",
"lucide-react": "^0.451.0", "lucide-react": "^0.451.0",
"next": "15.0.3", "next": "15.0.3",
"postcss": "8.4.47", "postcss": "8.4.47",

25
lcbp3.code-workspace Normal file
View File

@@ -0,0 +1,25 @@
{
"folders": [
{
"path": "."
},
{
"path": "../Documents"
}
],
"settings": {
"git.confirmSync": false,
"terminal.integrated.profiles.windows": {
"PowerShell (Desktop)": {
"path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"QNAP SSH": {
"path": "C:\\Windows\\System32\\OpenSSH\\ssh.exe",
"args": ["qnap"]
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell (Desktop)",
"debug.javascript.autoAttachFilter": "smart",
"sqltools.connections": []
}
}