Skip to content
Snippets Groups Projects
Commit e0ea0904 authored by tpgus2603's avatar tpgus2603
Browse files

Merge branch 'deploy' of https://git.ajou.ac.kr/websystem1/webback into deploy

parents d5d6cbd7 8a447bbd
No related branches found
No related tags found
1 merge request!42[#25] 배포코드 master브랜치로 이동
......@@ -17,14 +17,33 @@ const app = express();
app.use(morgan('dev')); //로깅용
// CORS 설정
app.use(
cors({
origin: process.env.FRONTEND_URL,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
})
);
const corsOptions = {
origin: (origin, callback) => {
console.log('CORS Origin:', origin); // 디버깅용 로그
const allowedOrigins = [
'http://localhost:3000', // 로컬 개발 환경
'http://ec2-43-203-68-83.ap-northeast-2.compute.amazonaws.com', // EC2 백엔드
];
if (!origin) return callback(null, true); // origin이 없으면 허용 (e.g., Postman)
if (allowedOrigins.includes(origin)) {
return callback(null, true);
}
console.log('CORS origin rejected:', origin); // 차단된 origin 로그
return callback(new Error('Not allowed by CORS'));
},
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true, // 쿠키 허용
};
// CORS 미들웨어 적용
app.use(cors(corsOptions));
// Preflight 요청 처리
app.options('*', cors(corsOptions));
//
app.use(
session({
......@@ -34,9 +53,9 @@ app.use(
rolling: true,
cookie: {
httpOnly: true,
secure: false,
secure: true,
maxAge: 60 * 60 * 1000, // 1시간
sameSite: 'lax',
sameSite: 'none',
},
})
);
......@@ -55,7 +74,7 @@ app.use(flash());
console.log('MongoDB URI:', process.env.MONGO_URI);
//라우터 등록
const authRoutes = require('./routes/auth');
app.use('/auth', authRoutes);
app.use('/api/auth',authRoutes);
const scheduleRoutes = require('./routes/schedule');
app.use('/api/schedule', scheduleRoutes);
......@@ -92,4 +111,4 @@ const PORT = process.env.PORT || 3000;
console.error('❌ 서버 시작 중 오류 발생:', error);
process.exit(1);
}
})();
\ No newline at end of file
})();
MongoDB URI: mongodb+srv://admin:lim1234!!@goodmeeting.vkniz.mongodb.net/
(node:44244) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(node:4550) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(Use `node --trace-warnings ...` to show where the warning was created)
(node:44244) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(node:4550) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
✅ MongoDB 연결 성공
Rdb데이터베이스 연결 성공.
모든 모델이 성공적으로 동기화되었습니다.
Server is running on 8080
CORS Origin: undefined
GET /api/auth/login 302 7.628 ms - 0
CORS Origin: undefined
GET /api/schedule/all 401 3.639 ms - 44
CORS Origin: undefined
GET /api/schedule/all 401 1.347 ms - 44
......@@ -3,7 +3,7 @@ const passport = require('passport');
const router = express.Router();
// GET /auth/login
// GET api/auth/login
router.get('/login', (req, res, next) => {
// 프론트엔드에서 전달한 redirectUrl 가져오기
const redirectUrl = req.query.redirectUrl || process.env.FRONTEND_URL || 'http://localhost:3000';
......
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module './resources/firebase/yanawa-89d9d-firebase-adminsdk-d1inm-24566bf0b9.json'
Require stack:
- /home/ubuntu/webback/wsServer.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/home/ubuntu/webback/wsServer.js:18:37)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/ubuntu/webback/wsServer.js' ]
(node:4551) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4551) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
MongoDB 연결 실패: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at _handleConnectionErrors (/home/ubuntu/webback/node_modules/mongoose/lib/connection.js:909:11)
at NativeConnection.openUri (/home/ubuntu/webback/node_modules/mongoose/lib/connection.js:860:11)
at async connectMongoDB (/home/ubuntu/webback/wsServer.js:28:5) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
Node.js v18.20.5
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment