You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cors.go 828B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import (
  5. "time"
  6. "code.gitea.io/gitea/modules/log"
  7. )
  8. // CORSConfig defines CORS settings
  9. var CORSConfig = struct {
  10. Enabled bool
  11. Scheme string
  12. AllowDomain []string
  13. AllowSubdomain bool
  14. Methods []string
  15. MaxAge time.Duration
  16. AllowCredentials bool
  17. Headers []string
  18. XFrameOptions string
  19. }{
  20. Enabled: false,
  21. MaxAge: 10 * time.Minute,
  22. Headers: []string{"Content-Type", "User-Agent"},
  23. XFrameOptions: "SAMEORIGIN",
  24. }
  25. func newCORSService() {
  26. sec := Cfg.Section("cors")
  27. if err := sec.MapTo(&CORSConfig); err != nil {
  28. log.Fatal("Failed to map cors settings: %v", err)
  29. }
  30. if CORSConfig.Enabled {
  31. log.Info("CORS Service Enabled")
  32. }
  33. }