m8chaa Claude commited on
Commit
a56d4ce
·
1 Parent(s): de4b61a

fix: revert to Next.js server mode with standalone build

Browse files

- Restore Next.js API routes for proper development workflow
- Configure Next.js standalone mode for Docker deployment
- Update Dockerfile to copy standalone build artifacts
- Frontend calls /api/analyze (Next.js) → FastAPI backend

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Dockerfile CHANGED
@@ -61,8 +61,9 @@ RUN pip install --no-cache-dir -r requirements.txt
61
  # Copy backend source code
62
  COPY securecheck-pro/backend/ .
63
 
64
- # Copy built frontend static files
65
- COPY --from=frontend-builder /app/frontend/out ./static
 
66
  COPY --from=frontend-builder /app/frontend/public ./public
67
 
68
  # Set proper ownership for the app directory
 
61
  # Copy backend source code
62
  COPY securecheck-pro/backend/ .
63
 
64
+ # Copy built frontend files (Next.js standalone build)
65
+ COPY --from=frontend-builder /app/frontend/.next/standalone ./
66
+ COPY --from=frontend-builder /app/frontend/.next/static ./.next/static
67
  COPY --from=frontend-builder /app/frontend/public ./public
68
 
69
  # Set proper ownership for the app directory
securecheck-pro/frontend/next.config.ts CHANGED
@@ -1,9 +1,8 @@
1
  import type { NextConfig } from "next";
2
 
3
  const nextConfig: NextConfig = {
4
- // Static export for Docker deployment
5
- output: 'export',
6
- trailingSlash: true,
7
  images: {
8
  unoptimized: true
9
  }
 
1
  import type { NextConfig } from "next";
2
 
3
  const nextConfig: NextConfig = {
4
+ // Standalone mode for Docker deployment
5
+ output: 'standalone',
 
6
  images: {
7
  unoptimized: true
8
  }
securecheck-pro/frontend/src/app/api/analyze/route.ts ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:8000';
4
+
5
+ export async function POST(request: NextRequest) {
6
+ try {
7
+ const { url } = await request.json();
8
+
9
+ if (!url) {
10
+ return NextResponse.json(
11
+ { error: 'URL이 필요합니다.' },
12
+ { status: 400 }
13
+ );
14
+ }
15
+
16
+ // 백엔드 FastAPI로 분석 요청 전달
17
+ const response = await fetch(`${API_BASE_URL}/api/v1/analyze`, {
18
+ method: 'POST',
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ body: JSON.stringify({ url }),
23
+ });
24
+
25
+ if (!response.ok) {
26
+ const errorData = await response.json().catch(() => ({}));
27
+ return NextResponse.json(
28
+ { error: errorData.detail || '분석 중 오류가 발생했습니다.' },
29
+ { status: response.status }
30
+ );
31
+ }
32
+
33
+ const data = await response.json();
34
+ return NextResponse.json(data);
35
+
36
+ } catch (error) {
37
+ console.error('Analyze API error:', error);
38
+ return NextResponse.json(
39
+ { error: '서버 오류가 발생했습니다.' },
40
+ { status: 500 }
41
+ );
42
+ }
43
+ }
securecheck-pro/frontend/src/components/SecurityAnalyzer.tsx CHANGED
@@ -46,8 +46,7 @@ export function SecurityAnalyzer() {
46
  setResult(null);
47
 
48
  try {
49
- // Call FastAPI backend directly
50
- const response = await fetch('/api/v1/analyze', {
51
  method: 'POST',
52
  headers: {
53
  'Content-Type': 'application/json',
 
46
  setResult(null);
47
 
48
  try {
49
+ const response = await fetch('/api/analyze', {
 
50
  method: 'POST',
51
  headers: {
52
  'Content-Type': 'application/json',