File tree Expand file tree Collapse file tree 2 files changed +4
-33
lines changed Expand file tree Collapse file tree 2 files changed +4
-33
lines changed Original file line number Diff line number Diff line change 1
1
package serverHandler
2
2
3
3
import (
4
- "../util"
5
4
"net/http"
6
- "strings"
7
5
)
8
6
9
- func (h * handler ) cors (w http.ResponseWriter , r * http. Request ) {
7
+ func (h * handler ) cors (w http.ResponseWriter ) {
10
8
header := w .Header ()
11
9
12
10
header .Set ("Access-Control-Allow-Origin" , "*" )
13
-
14
- if r .Method != http .MethodOptions {
15
- return
16
- }
17
-
18
- // Access-Control-Allow-Methods
19
- acAllowMethods := []string {
20
- http .MethodGet ,
21
- http .MethodHead ,
22
- http .MethodPost ,
23
- http .MethodPut ,
24
- http .MethodDelete ,
25
- http .MethodOptions ,
26
- http .MethodTrace ,
27
- }
28
- acReqMethods := r .Header ["Access-Control-Request-Method" ]
29
- if len (acReqMethods ) > 0 {
30
- acReqMethod := acReqMethods [0 ]
31
- if ! util .Contains (acAllowMethods , acReqMethod ) {
32
- acAllowMethods = append (acAllowMethods , acReqMethod )
33
- }
34
- }
35
- header .Set ("Access-Control-Allow-Methods" , strings .Join (acAllowMethods , ", " ))
36
-
37
- // Access-Control-Allow-Headers
38
- acAllowHeaders := r .Header ["Access-Control-Request-Headers" ]
39
- if len (acAllowHeaders ) > 0 {
40
- header .Set ("Access-Control-Allow-Headers" , strings .Join (acAllowHeaders , ", " ))
41
- }
11
+ header .Set ("Access-Control-Allow-Methods" , "*" )
12
+ header .Set ("Access-Control-Allow-Headers" , "*" )
42
13
}
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
104
104
h .header (w )
105
105
106
106
if data .CanCors {
107
- h .cors (w , r )
107
+ h .cors (w )
108
108
}
109
109
110
110
if data .IsMutate {
You can’t perform that action at this time.
0 commit comments