690401:2223 fix double warp by cluade opus local work
CI / CD Pipeline / build (push) Successful in 26m9s
CI / CD Pipeline / deploy (push) Failing after 9m4s

This commit is contained in:
2026-04-01 22:23:06 +07:00
parent 1d868d10b3
commit 9e40fcc118
4 changed files with 55 additions and 28 deletions
+2 -7
View File
@@ -9,10 +9,6 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { json, urlencoded } from 'express';
import helmet from 'helmet';
// Import Custom Interceptors & Filters ที่สร้างใน T1.1
import { TransformInterceptor } from './common/interceptors/transform.interceptor';
import { HttpExceptionFilter } from './common/exceptions/http-exception.filter';
async function bootstrap() {
// 1. Create App
const app = await NestFactory.create(AppModule);
@@ -65,9 +61,8 @@ async function bootstrap() {
})
);
// ลงทะเบียน Global Interceptor และ Filter ที่เราสร้างไว้
app.useGlobalInterceptors(new TransformInterceptor());
app.useGlobalFilters(new HttpExceptionFilter());
// ⚠️ TransformInterceptor & HttpExceptionFilter ลงทะเบียนผ่าน APP_INTERCEPTOR/APP_FILTER ใน CommonModule แล้ว
// ห้ามลงทะเบียนซ้ำที่นี่ เพราะจะทำให้ Response ถูก wrap ซ้อน 2 ชั้น
// 📘 6. Swagger Configuration
const swaggerConfig = new DocumentBuilder()
+49 -16
View File
@@ -6,10 +6,45 @@ import { auth } from '@/lib/auth';
// รายการ Route ที่ไม่ต้อง Login ก็เข้าได้ (Public Routes)
const publicRoutes = ['/login', '/register', '/'];
// 🛡️ Bot/Scanner Patterns - บล็อก requests ที่เป็น automated scanning
const blockedPatterns = [
// WordPress scanning
/\/wp-includes/i,
/\/wp-content/i,
/\/wp\//i,
/\/wordpress/i,
/\/xmlrpc\.php/i,
/wlwmanifest\.xml/i,
// Environment/config files
/\/\.env/i,
/\/\.env\./i,
/\/config\/\.env/i,
/\/api\/\.env/i,
// Database admin tools
/\/phpmyadmin/i,
/\/adminer/i,
/\/pma/i,
// Common scanner paths
/\/\.git/i,
/\/\.svn/i,
/\/config\.json/i,
/\/package\.json/i,
];
function isBlockedPath(path: string): boolean {
return blockedPatterns.some((pattern) => pattern.test(path));
}
export default auth((req) => {
const isLoggedIn = !!req.auth;
const { nextUrl } = req;
// 🛡️ 0. Block Bot/Scanner Requests (ไม่ส่งต่อไป backend)
if (isBlockedPath(nextUrl.pathname)) {
return new NextResponse(null, { status: 404 });
}
const isLoggedIn = !!req.auth;
const isPublicRoute = publicRoutes.includes(nextUrl.pathname);
const isAuthRoute = nextUrl.pathname.startsWith('/api/auth');
@@ -56,21 +91,19 @@ export default auth((req) => {
}
}
const cspHeader = `
default-src 'self';
script-src 'self' 'nonce-${nonce}' 'strict-dynamic' 'unsafe-eval';
style-src 'self' 'unsafe-inline';
img-src 'self' blob: data: https:;
font-src 'self' data:;
connect-src 'self' ws: wss: ${connectSrcApi};
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
upgrade-insecure-requests;
`
.replace(/\s{2,}/g, ' ')
.trim();
const cspHeader = [
"default-src 'self'",
`script-src 'self' 'nonce-${nonce}' 'strict-dynamic' 'unsafe-eval' 'unsafe-inline' http: https:`,
"style-src 'self' 'unsafe-inline'",
"img-src 'self' blob: data: https:",
"font-src 'self' data:",
`connect-src 'self' ws: wss: ${connectSrcApi}`,
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'none'",
"upgrade-insecure-requests",
].join('; ');
const requestHeaders = new Headers(req.headers);
requestHeaders.set('x-nonce', nonce);
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

+3 -4
View File
@@ -1,6 +1,5 @@
# Block all crawlers from accessing any part of the site
# This is an API/application server, not a content site
User-agent: *
Disallow: /api/
Allow: /
Disallow: /
# Sitemap
# Sitemap: https://your-domain.com/sitemap.xml