1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-01-24 03:47:38 +02:00

API: Set Access-Control-Allow-Headers when --api-cors is set

This commit is contained in:
Ralph Slooten 2023-05-04 22:23:07 +12:00
parent 14a61859f0
commit 16bc025fff

View File

@ -123,6 +123,7 @@ func middleWareFunc(fn http.HandlerFunc) http.HandlerFunc {
if AccessControlAllowOrigin != "" && strings.HasPrefix(r.RequestURI, config.Webroot+"api/") {
w.Header().Set("Access-Control-Allow-Origin", AccessControlAllowOrigin)
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
w.Header().Set("Access-Control-Allow-Headers", "*")
}
if config.UIAuthFile != "" {
@ -161,6 +162,7 @@ func middlewareHandler(h http.Handler) http.Handler {
if AccessControlAllowOrigin != "" && strings.HasPrefix(r.RequestURI, config.Webroot+"api/") {
w.Header().Set("Access-Control-Allow-Origin", AccessControlAllowOrigin)
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
w.Header().Set("Access-Control-Allow-Headers", "*")
}
if config.UIAuthFile != "" {