Membrane API Gateway returns 404 Not Found with the title Invalid path or method when a request arrives on one of its ports, but no API matches the request. Membrane does not know where to route the request and rejects it.
The response contains the status 404 Not Found, the title Invalid path or method, the message The requested path or HTTP method is not supported., 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, not an internal failure of the gateway.
For every incoming request, Membrane looks for an api whose criteria all match the request:
| Criterion | Configuration | Default |
|---|---|---|
| Port | port | Required |
| Host header | host | Any host |
| HTTP method | method | Any method |
| Path | path.uri, or the base paths of an openapi document | Any path |
If no API on the port matches, Membrane answers with this error. The APIs are checked in the order in which they appear in the configuration, and the first match wins.
A path is matched as a prefix. The following API accepts /shop/products and /shop/orders/7, but a request to /products or /Shop fails with Invalid path or method:
api:
port: 2000
path:
uri: /shop
target:
url: https://api.predic8.de
api:
port: 2000
path:
uri: /shop
target:
url: https://api.predic8.de
Check the request URL for typos, missing prefixes and case. If isRegExp: true is set, the uri is treated as a regular expression, so check that the expression matches the path.
An API with a method accepts only that HTTP method. A POST to this API is rejected:
api:
port: 2000
method: GET
path:
uri: /shop
target:
url: https://api.predic8.de
api:
port: 2000
method: GET
path:
uri: /shop
target:
url: https://api.predic8.de
Remove method to accept all methods, or add another API for the missing method.
With host set, the Host header of the request must match. Calling the gateway by IP address or through localhost instead of the configured host name fails.
An API deployed from an OpenAPI document is routed using the paths of the servers URLs in that document. If the servers URL is https://api.example.com/shop/v2, requests must start with /shop/v2.
If there is no API for the path on the port you are calling, the request cannot be routed, even if another port has a matching API. Check the port in the URL against the port of your APIs.
Host header, method and path of the failing request.api definitions in your apis.yaml.To accept all remaining requests on a port, place a catch-all API without path and method after the more specific ones:
api:
port: 2000
path:
uri: /shop
target:
url: https://api.predic8.de
---
api:
port: 2000
flow:
- return:
status: 404
api:
port: 2000
path:
uri: /shop
target:
url: https://api.predic8.de
---
api:
port: 2000
flow:
- return:
status: 404
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.