@@ -27,7 +27,7 @@ const port = process.env.PORT;
2727 */
2828app . use ( ( req , res , next ) => {
2929 res . success = ( success ) => {
30- return res . json ( { resultType : "SUCCESS" , error : null , data :success } ) ;
30+ return res . json ( { resultType : "SUCCESS" , error : null , data : success } ) ;
3131 } ;
3232
3333 res . error = ( { errorCode = "unknown" , reason = null , data = null } ) => {
@@ -42,24 +42,29 @@ app.use((req, res, next) => {
4242} ) ;
4343/** session */
4444app . use (
45- session ( {
46- cookie : {
47- maxAge : 7 * 24 * 60 * 60 * 1000 , // ms
48- } ,
49- resave : false ,
50- saveUninitialized : false ,
51- secret : process . env . EXPRESS_SESSION_SECRET ,
52- store : new PrismaSessionStore ( prisma , {
53- checkPeriod : 2 * 60 * 1000 , // ms
54- dbRecordIdIsSessionId : true ,
55- dbRecordIdFunction : undefined ,
56- } ) ,
57- } )
45+ session ( {
46+ cookie : {
47+ maxAge : 7 * 24 * 60 * 60 * 1000 , // ms
48+ } ,
49+ resave : false ,
50+ saveUninitialized : false ,
51+ secret : process . env . EXPRESS_SESSION_SECRET ,
52+ store : new PrismaSessionStore ( prisma , {
53+ checkPeriod : 2 * 60 * 1000 , // ms
54+ dbRecordIdIsSessionId : true ,
55+ dbRecordIdFunction : undefined ,
56+ } ) ,
57+ } )
5858) ;
5959app . use ( passport . initialize ( ) ) ;
6060app . use ( passport . session ( ) ) ;
6161
62- app . use ( cors ( ) ) ; // cors 방식 허용
62+ const corsOptions = {
63+ origin : [ process . env . LOCAL_ORIGIN , process . env . PROD_ORIGIN ] ,
64+ credentials : true ,
65+ } ;
66+
67+ app . use ( cors ( corsOptions ) ) ; // cors 방식 허용
6368app . use ( express . static ( "public" ) ) ; // 정적 파일 접근
6469app . use ( express . json ( ) ) ; // request의 본문을 json으로 해석할 수 있도록 함 (JSON 형태의 요청 body를 파싱하기 위함)
6570app . use ( express . urlencoded ( { extended : false } ) ) ; // 단순 객체 문자열 형태로 본문 데이터 해석
0 commit comments