Closed yasuto2002 closed 1 year ago
func commonMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
next.ServeHTTP(w, r)
})
}
https://qiita.com/2san/items/dd2c6d0449262a42b728 https://stackoverflow.com/questions/51456253/how-to-set-http-responsewriter-content-type-header-globally-for-all-api-endpoint
headers := handlers.AllowedHeaders([]string{"*", "Content-Type", "*"})
origins := handlers.AllowedOrigins([]string{"*"})
methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"})
http.ListenAndServe(":"+port, handlers.CORS(headers, origins, methodsOk)(r))
https://pkg.go.dev/github.com/gorilla/handlers#AllowedHeaders
apiリクエストを送ると文字列で返ってきてしまう
少し気持ち悪いので修正したい!!