MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / AddCorsOption

Method AddCorsOption

agent/utils/nginx/components/server.go:559–580  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

557}
558
559func (s *Server) AddCorsOption() {
560 newDir := &Directive{
561 Name: "if",
562 Parameters: []string{"(", "$request_method", "=", "'OPTIONS'", ")"},
563 Block: &Block{},
564 }
565 block := &Block{}
566 block.AppendDirectives(&Directive{
567 Name: "return",
568 Parameters: []string{"204"},
569 })
570 newDir.Block = block
571 directives := s.GetDirectives()
572 newDirectives := make([]IDirective, 0)
573 for _, dir := range directives {
574 if dir.GetName() != "listen" {
575 newDirectives = append(newDirectives, dir)
576 }
577 }
578 newDirectives = append(newDirectives, newDir)
579 s.Directives = newDirectives
580}

Callers 1

UpdateCorsMethod · 0.45

Calls 3

AppendDirectivesMethod · 0.95
GetDirectivesMethod · 0.95
GetNameMethod · 0.65

Tested by

no test coverage detected