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

conflict 해결

parents 1b9c7336 64c26d78
No related branches found
No related tags found
1 merge request!42[#25] 배포코드 master브랜치로 이동
......@@ -17,9 +17,18 @@ const app = express();
app.use(morgan('dev')); //로깅용
// CORS 설정
<<<<<<< HEAD
app.use(
cors({
origin: process.env.FRONTEND_URL,
=======
// CORS 설정
app.use(
cors({
origin: 'https://yanawa.shop',
>>>>>>> 64c26d78b38c309501ec96a24f94617332a4adb4
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
......@@ -41,7 +50,6 @@ app.use(
})
);
// 미들웨어 설정
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
......@@ -52,6 +60,9 @@ app.use(passport.session());
app.use(flash());
app.set('trust proxy', 1);
console.log('MongoDB URI:', process.env.MONGO_URI);
//라우터 등록
const authRoutes = require('./routes/auth');
......
MongoDB URI: mongodb+srv://admin:lim1234!!@goodmeeting.vkniz.mongodb.net/
(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
(node:17474) [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: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
(node:17474) [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
GET /api/ 404 6.385 ms - 143
......@@ -7,7 +7,6 @@ module.exports = new GoogleStrategy(
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: process.env.CALLBACK_URL,
passReqToCallback: true, // req 객체를 콜백에 전달
},
async (req, accessToken, refreshToken, profile, done) => {
try {
......
......@@ -6,13 +6,8 @@ const router = express.Router();
// GET api/auth/login
router.get('/login', (req, res, next) => {
// 프론트엔드에서 전달한 redirectUrl 가져오기
const redirectUrl = req.query.redirectUrl || process.env.FRONTEND_URL || 'http://localhost:3000';
// redirectUrl 유효성 검증
const allowedDomains = [process.env.FRONTEND_URL || 'http://localhost:3000'];
if (!allowedDomains.some((domain) => redirectUrl.startsWith(domain))) {
return res.status(400).json({ error: 'Invalid redirect URL' });
}
const redirectUrl = req.query.redirectUrl || process.env.FRONTEND_URL || 'https://yanawa.shop';
// redirectUrl 유효성 검증
// redirectUrl 세션에 저장
req.session.redirectUrl = redirectUrl;
......@@ -20,20 +15,23 @@ router.get('/login', (req, res, next) => {
// Google OAuth 인증 시작
passport.authenticate('google', { scope: ['profile', 'email'] })(req, res, next);
});
// GET /auth/google/callback
router.get(
'/google/callback',
passport.authenticate('google', { failureRedirect: '/auth/login' }),
(req, res) => {
// 세션에서 redirectUrl 가져오기
const redirectUrl = req.session.redirectUrl || process.env.FRONTEND_URL || 'http://localhost:3000';
const redirectUrl = req.session.redirectUrl || 'https://yanawa.shop';
// 세션에서 redirectUrl 제거
req.session.redirectUrl = null;
// 인증 완료 후 프론트엔드로 리다이렉트
res.redirect(redirectUrl);
req.session.save((err) => {
if (err) {
console.error('세션 저장 오류:', err);
return res.status(500).json({ error: '서버 오류' });
}
res.redirect(redirectUrl);
});
}
);
......
(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
(node:17475) [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
(node:17475) [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)
......
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