Trim / from end of origin

This commit is contained in:
Melon 2023-12-14 23:50:09 +00:00
parent be3a09b73a
commit 03df1556e7
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -9,6 +9,7 @@ import (
"github.com/rs/cors" "github.com/rs/cors"
"log" "log"
"net/http" "net/http"
"strings"
"sync/atomic" "sync/atomic"
"time" "time"
) )
@ -71,7 +72,7 @@ func NewHttpServer(conf Conf, signer mjwt.Signer) *HttpServer {
var corsAccessControl = cors.New(cors.Options{ var corsAccessControl = cors.New(cors.Options{
AllowOriginFunc: func(origin string) bool { AllowOriginFunc: func(origin string) bool {
load := hs.services.Load() load := hs.services.Load()
_, ok := (*load)[origin] _, ok := (*load)[strings.TrimSuffix(origin, "/")]
return ok return ok
}, },
AllowedMethods: []string{http.MethodPost, http.MethodOptions}, AllowedMethods: []string{http.MethodPost, http.MethodOptions},