fix: forward request Host to errors middleware service

Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
Kevin Pollet 2021-09-27 17:40:13 +02:00 committed by GitHub
parent 126b32c579
commit 46c1600ada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 24 deletions

View file

@ -27,10 +27,7 @@ var (
_ middlewares.Stateful = &codeCatcherWithCloseNotify{}
)
const (
typeName = "customError"
backendURL = "http://0.0.0.0"
)
const typeName = "customError"
type serviceBuilder interface {
BuildHTTP(ctx context.Context, serviceName string) (http.Handler, error)
@ -104,7 +101,7 @@ func (c *customErrors) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
query = strings.ReplaceAll(query, "{status}", strconv.Itoa(code))
}
pageReq, err := newRequest(backendURL + query)
pageReq, err := newRequest("http://" + req.Host + query)
if err != nil {
logger.Error(err)
rw.WriteHeader(code)