Skip to content

Commit 55545df

Browse files
committed
bug fix: error on handling a normal request
1 parent 568bc55 commit 55545df

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ gocors
33

44
A tiny toolkit for Go CORS support.
55

6-
### Explanation:
6+
### <EM></EM>xplanation:
77

88
CORS means "Cross-Origin Resource Sharing", which your can find more info here[http://enable-cors.org/]
99

cors.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gocors
22

33
import (
4+
"io"
45
"log"
56
"net/http"
67
"strconv"
@@ -104,7 +105,8 @@ func (cors *Cors) Handler(h http.Handler) http.Handler {
104105

105106
func (cors *Cors) ServeHTTP(w http.ResponseWriter, r *http.Request) {
106107
if origin := r.Header.Get("Origin"); origin == "" {
107-
cors.corsNotValid(w, r)
108+
//cors.corsNotValid(w, r)
109+
cors.userHandler.ServeHTTP(w, r)
108110
return
109111
} else if r.Method != "OPTIONS" {
110112
//actual request.
@@ -161,6 +163,7 @@ func (cors *Cors) preflightRequest(w http.ResponseWriter, r *http.Request) {
161163

162164
func (cors *Cors) corsNotValid(w http.ResponseWriter, r *http.Request) {
163165
r.Header.Set("Content-Type", "text/html; charset=utf-8")
166+
io.WriteString(w, "CORS Request Invalid")
164167
return
165168
}
166169

0 commit comments

Comments
 (0)