251004 frontend backend
This commit is contained in:
		
							
								
								
									
										17
									
								
								backend/src/utils/cookie.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								backend/src/utils/cookie.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| // FILE: backend/src/utils/cookie.js | ||||
| export const cookieOpts = (maxAgeMs) => { | ||||
|   const isProd = process.env.NODE_ENV === "production"; | ||||
|   const opts = { | ||||
|     httpOnly: true, | ||||
|     secure: true, // หลัง Nginx/HTTPS | ||||
|     sameSite: "none", // ส่งข้าม subdomain ได้ | ||||
|     path: "/", | ||||
|     maxAge: maxAgeMs, | ||||
|   }; | ||||
|   if (process.env.COOKIE_DOMAIN) opts.domain = process.env.COOKIE_DOMAIN; // เช่น .np-dms.work | ||||
|   if (!isProd && process.env.ALLOW_INSECURE_COOKIE === "1") { | ||||
|     opts.secure = false; | ||||
|     opts.sameSite = "lax"; | ||||
|   } | ||||
|   return opts; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user
	 admin
					admin