新增自定义的 Cors
This commit is contained in:
@@ -3,10 +3,12 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/server/upload/internal/config"
|
||||
"fusenapi/server/upload/internal/handler"
|
||||
"fusenapi/server/upload/internal/svc"
|
||||
"fusenapi/utils/auth"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
@@ -20,7 +22,9 @@ func main() {
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCors())
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
}))
|
||||
defer server.Stop()
|
||||
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
Reference in New Issue
Block a user