gitea源码

cors.go 874B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import (
  5. "time"
  6. )
  7. // CORSConfig defines CORS settings
  8. var CORSConfig = struct {
  9. Enabled bool
  10. 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.
  11. Methods []string
  12. MaxAge time.Duration
  13. AllowCredentials bool
  14. Headers []string
  15. XFrameOptions string
  16. }{
  17. AllowDomain: []string{"*"},
  18. Methods: []string{"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
  19. Headers: []string{"Content-Type", "User-Agent"},
  20. MaxAge: 10 * time.Minute,
  21. XFrameOptions: "SAMEORIGIN",
  22. }
  23. func loadCorsFrom(rootCfg ConfigProvider) {
  24. mustMapSetting(rootCfg, "cors", &CORSConfig)
  25. }