allows cross origin downloads
This commit is contained in:
parent
9bd7e5fb14
commit
974f6aef63
1
main.go
1
main.go
@ -14,6 +14,7 @@ var hidden = flag.Bool("hidden", false, "allow serving hidden dirs")
|
|||||||
|
|
||||||
func logger(h http.Handler) http.Handler {
|
func logger(h http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
log.Printf("%s: %s\n", r.RemoteAddr, r.URL)
|
log.Printf("%s: %s\n", r.RemoteAddr, r.URL)
|
||||||
if !*hidden && strings.Contains(r.URL.Path, "/.") {
|
if !*hidden && strings.Contains(r.URL.Path, "/.") {
|
||||||
http.Error(w, "hidden files and directories are not allowed", http.StatusUnauthorized)
|
http.Error(w, "hidden files and directories are not allowed", http.StatusUnauthorized)
|
||||||
|
Loading…
Reference in New Issue
Block a user