| 
									
										
										
										
											2019-08-15 14:42:30 +05:30
										 |  |  | import { homeLocation } from '../../../config/env'; | 
					
						
							| 
									
										
										
										
											2020-09-07 11:04:44 +05:30
										 |  |  | import { allowedOrigins } from '../../../config/cors-settings'; | 
					
						
							| 
									
										
										
										
											2019-08-15 14:42:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-04 01:25:34 -07:00
										 |  |  | export default function constantHeaders() { | 
					
						
							|  |  |  |   return function(req, res, next) { | 
					
						
							| 
									
										
										
										
											2020-03-03 20:32:04 +05:30
										 |  |  |     if ( | 
					
						
							|  |  |  |       req.headers && | 
					
						
							|  |  |  |       req.headers.origin && | 
					
						
							| 
									
										
										
										
											2020-09-07 11:04:44 +05:30
										 |  |  |       allowedOrigins.includes(req.headers.origin) | 
					
						
							| 
									
										
										
										
											2020-03-03 20:32:04 +05:30
										 |  |  |     ) { | 
					
						
							|  |  |  |       res.header('Access-Control-Allow-Origin', req.headers.origin); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       res.header('Access-Control-Allow-Origin', homeLocation); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-15 14:42:30 +05:30
										 |  |  |     res.header('Access-Control-Allow-Credentials', true); | 
					
						
							| 
									
										
										
										
											2019-02-18 19:32:49 +00:00
										 |  |  |     res.header( | 
					
						
							|  |  |  |       'Access-Control-Allow-Headers', | 
					
						
							| 
									
										
										
										
											2015-08-04 01:25:34 -07:00
										 |  |  |       'Origin, X-Requested-With, Content-Type, Accept' | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     next(); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |