-
Notifications
You must be signed in to change notification settings - Fork 2
Feat: 쿠키 기반의 인증 로직, 미들웨어, 인터셉터 개선 #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0f2dd13
5f708fd
7803831
ff3c043
228e2c9
1909ac5
82010e5
3be5025
05624fe
f6defbd
c17a494
af99575
815f1bd
0d63e27
3f6d241
4da933d
a920e3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # HTTPS 개발 서버 (JavaScript 파일) | ||
| server.mjs | ||
|
|
||
| # Next.js 빌드 출력 | ||
| .next/ | ||
| out/ | ||
|
|
||
| # 의존성 | ||
| node_modules/ | ||
|
|
||
| # 생성된 파일 | ||
| src/generated/ |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,38 @@ const nextConfig = { | |||||||||
| typescript: { ignoreBuildErrors: false }, | ||||||||||
| eslint: { ignoreDuringBuilds: false }, | ||||||||||
| output: 'standalone', | ||||||||||
| // 인증 관련 엔드포인트만 프록시 (쿠키 공유를 위해) | ||||||||||
| async rewrites() { | ||||||||||
| // HTTPS 환경에서만 프록시 활성화 | ||||||||||
| // HTTP 개발 환경(CSR only)에서는 프록시 비활성화 | ||||||||||
| const proxyEnabled = | ||||||||||
| process.env.NEXT_PUBLIC_ENABLE_PROXY !== 'false'; | ||||||||||
|
|
||||||||||
| if (!proxyEnabled) { | ||||||||||
| console.log( | ||||||||||
| '[Next.js] 🚫 프록시 비활성화 - HTTP CSR 전용 모드', | ||||||||||
| ); | ||||||||||
| return []; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const apiBaseUrl = | ||||||||||
| process.env.NEXT_PUBLIC_API_BASE_URL || | ||||||||||
| 'https://soso.dreampaste.com'; | ||||||||||
|
|
||||||||||
| console.log('[Next.js] ✅ 프록시 활성화 - HTTPS 전체 기능 모드'); | ||||||||||
|
||||||||||
| console.log('[Next.js] ✅ 프록시 활성화 - HTTPS 전체 기능 모드'); | |
| if (process.env.NODE_ENV === 'development') { | |
| console.log('[Next.js] ✅ 프록시 활성화 - HTTPS 전체 기능 모드'); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { createServer } from 'https'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { parse } from 'url'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import next from 'next'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import fs from 'fs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { fileURLToPath } from 'url'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { dirname, join } from 'path'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const __filename = fileURLToPath(import.meta.url); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const __dirname = dirname(__filename); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const dev = process.env.NODE_ENV !== 'production'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| const hostname = 'localhost'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| const port = 3000; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // SSL 인증서 로드 | ||||||||||||||||||||||||||||||||||||||||||||||||
| const httpsOptions = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| key: fs.readFileSync(join(__dirname, '.cert', 'localhost+2-key.pem')), | ||||||||||||||||||||||||||||||||||||||||||||||||
| cert: fs.readFileSync(join(__dirname, '.cert', 'localhost+2.pem')), | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+19
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const httpsOptions = { | |
| key: fs.readFileSync(join(__dirname, '.cert', 'localhost+2-key.pem')), | |
| cert: fs.readFileSync(join(__dirname, '.cert', 'localhost+2.pem')), | |
| }; | |
| const certDir = process.env.SSL_CERT_DIR || join(__dirname, '.cert'); | |
| const certFiles = ['localhost+2', 'localhost', 'local']; | |
| let httpsOptions; | |
| for (const name of certFiles) { | |
| try { | |
| httpsOptions = { | |
| key: fs.readFileSync(join(certDir, `${name}-key.pem`)), | |
| cert: fs.readFileSync(join(certDir, `${name}.pem`)), | |
| }; | |
| break; | |
| } catch (e) { | |
| // 다음 패턴 시도 | |
| } | |
| } | |
| if (!httpsOptions) { | |
| throw new Error( | |
| `SSL 인증서 파일을 찾을 수 없습니다. ${certDir} 경로에 인증서 파일이 있는지 확인하세요.` | |
| ); | |
| } |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
에러 메시지가 너무 간단하여 디버깅에 도움이 되지 않습니다. 에러 상세 정보를 포함하는 것이 좋습니다.
제안:
} catch (err) {
console.error('Error occurred handling', req.url, err);
res.statusCode = 500;
res.end(`Internal server error: ${err.message || 'Unknown error'}`);
}| res.end('internal server error'); | |
| } | |
| if (dev) { | |
| res.end(`Internal server error: ${err.message || 'Unknown error'}`); | |
| } else { | |
| res.end('internal server error'); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빌드 시마다 프록시 비활성화 로그가 출력되면 불필요한 로그가 발생합니다. 개발 환경에서만 로깅하는 것이 좋습니다.
해결 방법: