|  | @@ -0,0 +1,30 @@
 | 
	
		
			
			|  | 1 | +package cors
 | 
	
		
			
			|  | 2 | +
 | 
	
		
			
			|  | 3 | +import (
 | 
	
		
			
			|  | 4 | +	"net/http"
 | 
	
		
			
			|  | 5 | +	"strings"
 | 
	
		
			
			|  | 6 | +
 | 
	
		
			
			|  | 7 | +	"github.com/gin-contrib/cors"
 | 
	
		
			
			|  | 8 | +	"github.com/gin-gonic/gin"
 | 
	
		
			
			|  | 9 | +)
 | 
	
		
			
			|  | 10 | +
 | 
	
		
			
			|  | 11 | +func Cors() gin.HandlerFunc {
 | 
	
		
			
			|  | 12 | +	config := cors.DefaultConfig()
 | 
	
		
			
			|  | 13 | +
 | 
	
		
			
			|  | 14 | +	config.AddAllowMethods(http.MethodDelete, http.MethodOptions, http.MethodPatch)
 | 
	
		
			
			|  | 15 | +	config.AddAllowHeaders("Authorization", "X-Require-Cookie")
 | 
	
		
			
			|  | 16 | +	config.AllowCredentials = true
 | 
	
		
			
			|  | 17 | +	config.AllowOriginFunc = func(origin string) bool {
 | 
	
		
			
			|  | 18 | +		if gin.Mode() == gin.DebugMode {
 | 
	
		
			
			|  | 19 | +			return true
 | 
	
		
			
			|  | 20 | +		}
 | 
	
		
			
			|  | 21 | +
 | 
	
		
			
			|  | 22 | +		if strings.Contains(origin, "links123.com") {
 | 
	
		
			
			|  | 23 | +			return true
 | 
	
		
			
			|  | 24 | +		}
 | 
	
		
			
			|  | 25 | +
 | 
	
		
			
			|  | 26 | +		return false
 | 
	
		
			
			|  | 27 | +	}
 | 
	
		
			
			|  | 28 | +
 | 
	
		
			
			|  | 29 | +	return cors.New(config)
 | 
	
		
			
			|  | 30 | +}
 |