1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| func allowCrossOrigin() core.HandlerFunc { var uploaderAllowOriginRegexp = regexp.MustCompile(econf.GetString("crossOriginRegexp")) return func(c *core.Context) (err error) { origin := c.Request.Header.Get("Origin") if uploaderAllowOriginRegexp.MatchString(origin) { c.Header("Access-Control-Allow-Origin", origin) c.Header("Vary", "Origin") c.Header("Access-Control-Allow-Headers", c.GetHeader("Access-Control-Request-Headers")) c.Header("Access-Control-Allow-Methods", "GET,POST,PATCH,PUT,DELETE,OPTIONS,HEAD") c.Header("Access-Control-Allow-Credentials", "true") c.Header("Access-Control-Max-Age", "600") }
c.Next() return nil } }
|