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 767B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "time"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. var (
  10. // CORSConfig defines CORS settings
  11. CORSConfig = struct {
  12. Enabled bool
  13. Scheme string
  14. AllowDomain []string
  15. AllowSubdomain bool
  16. Methods []string
  17. MaxAge time.Duration
  18. AllowCredentials bool
  19. }{
  20. Enabled: false,
  21. MaxAge: 10 * time.Minute,
  22. }
  23. )
  24. func newCORSService() {
  25. sec := Cfg.Section("cors")
  26. if err := sec.MapTo(&CORSConfig); err != nil {
  27. log.Fatal("Failed to map cors settings: %v", err)
  28. }
  29. if CORSConfig.Enabled {
  30. log.Info("CORS Service Enabled")
  31. }
  32. }