mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 07:27:33 -04:00 
			
		
		
		
	Backport #26402 by cassiozareck Closes #25898 Signed-off-by: cassiozareck <cassiomilczareck@gmail.com> Co-authored-by: cassio zareck <121526696+cassiozareck@users.noreply.github.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
		
			
				
	
	
		
			30 lines
		
	
	
		
			874 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			874 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2019 The Gitea Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package setting
 | |
| 
 | |
| import (
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // CORSConfig defines CORS settings
 | |
| var CORSConfig = struct {
 | |
| 	Enabled          bool
 | |
| 	AllowDomain      []string // FIXME: this option is from legacy code, it actually works as "AllowedOrigins". When refactoring in the future, the config option should also be renamed together.
 | |
| 	Methods          []string
 | |
| 	MaxAge           time.Duration
 | |
| 	AllowCredentials bool
 | |
| 	Headers          []string
 | |
| 	XFrameOptions    string
 | |
| }{
 | |
| 	AllowDomain:   []string{"*"},
 | |
| 	Methods:       []string{"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
 | |
| 	Headers:       []string{"Content-Type", "User-Agent"},
 | |
| 	MaxAge:        10 * time.Minute,
 | |
| 	XFrameOptions: "SAMEORIGIN",
 | |
| }
 | |
| 
 | |
| func loadCorsFrom(rootCfg ConfigProvider) {
 | |
| 	mustMapSetting(rootCfg, "cors", &CORSConfig)
 | |
| }
 |