code.gitea.io/gitea@v1.19.3/modules/setting/cors.go (about) 1 // Copyright 2019 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package setting 5 6 import ( 7 "time" 8 9 "code.gitea.io/gitea/modules/log" 10 ) 11 12 // CORSConfig defines CORS settings 13 var CORSConfig = struct { 14 Enabled bool 15 Scheme string 16 AllowDomain []string 17 AllowSubdomain bool 18 Methods []string 19 MaxAge time.Duration 20 AllowCredentials bool 21 Headers []string 22 XFrameOptions string 23 }{ 24 AllowDomain: []string{"*"}, 25 Methods: []string{"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, 26 Headers: []string{"Content-Type", "User-Agent"}, 27 MaxAge: 10 * time.Minute, 28 XFrameOptions: "SAMEORIGIN", 29 } 30 31 func loadCorsFrom(rootCfg ConfigProvider) { 32 mustMapSetting(rootCfg, "cors", &CORSConfig) 33 if CORSConfig.Enabled { 34 log.Info("CORS Service Enabled") 35 } 36 }