This commit is contained in:
Sean Macdonald 2021-09-04 19:34:03 -04:00
parent 6c953e0326
commit d6469022fe
2 changed files with 10 additions and 10 deletions

View File

@ -101,9 +101,9 @@ func Serve() {
protocol = "https" protocol = "https"
} }
if Flags.CorsOrigin != "" { if Flags.CorsOrigin != "" {
stdout.Printf("CORS origin header is %s", Flags.CorsOrigin) stdout.Printf("CORS origin header is %s", Flags.CorsOrigin)
} }
if Flags.HttpSock == "" { if Flags.HttpSock == "" {
stdout.Printf("You can now upload files to: %s://%s%s", protocol, address, basepath) stdout.Printf("You can now upload files to: %s://%s%s", protocol, address, basepath)

View File

@ -217,15 +217,15 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
header := w.Header() header := w.Header()
var origin = handler.config.CorsOrigin var origin = handler.config.CorsOrigin
if origin == "" { if origin == "" {
origin = r.Header.Get("Origin") origin = r.Header.Get("Origin")
} }
if origin != "" { if origin != "" {
header.Set("Access-Control-Allow-Origin", origin) header.Set("Access-Control-Allow-Origin", origin)
header.Set("Vary", "Origin") header.Set("Vary", "Origin")
if r.Method == "OPTIONS" { if r.Method == "OPTIONS" {
// Preflight request // Preflight request