Membrane API Gateway returns 400 Bad Request with the title Request path or 'Host' header is malformed when the HTTP client at the end of the flow cannot build a valid backend URL. Nothing is sent to the backend.
The response contains the status 400 Bad Request, the title Request path or 'Host' header is malformed, the problem type https://membrane-api.io/problems/user and a link to this page. The type user means that the request or the configuration caused the problem. Although the title mentions the request, the cause is usually the gateway configuration.
The target of an API sets the destination of the request, either with a url or with host and port. The HTTP client then needs an absolute http:// or https:// URL with a valid host and port. If the destination is not such a URL, it reports this error.
api:
port: 2000
target:
url: https://api.predic8.de
api:
port: 2000
target:
url: https://api.predic8.de
The API has neither a target url nor a host, and no plugin set a destination. The destination is then the relative path of the request, for example /orders, which is not an absolute URL.
A target url that contains an expression evaluates to a string that is not a valid absolute URL, for example because a header or property it uses is missing or empty.
The host or port of the destination is invalid, for example a non-numeric port or a malformed IPv6 address.
When Membrane is used as a forward proxy, a request line that contains only a path instead of an absolute URL gives the gateway no host to connect to.
target with a valid absolute URL, or a host and port.Host header. When using Membrane as a forward proxy, use absolute URLs in the request line.By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:
configuration:
production: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.