A friend of mine was trying to set up an
api using Express in Azle. He hooked up a router to the top-level route
/api. I tested this out and I kept getting the error
Unexpected GET request path.
My suspicion is that something in the HTTP gateway is causing this to happen. Does anyone know what is going on? If this is a limitation of the HTTP gateway, can we get it changed? Not allowing developers to use the
/api route is a major bummer for the moment.
This looks like it is being routed directly to the replica instead of the HTTP gateway, which is unexpected. The boundary nodes will route calls matching a regex like this to the replica:
/api/v2/canister/[0-9a-zA-Z\-]+/query, which leaves room for developers to use any other endpoint starting with
Is the project hosted on mainnet? Can I test it out?
I only tested it locally, it was a simple Express app in Azle with a /api route, it should be really easy to reproduce I don’t imagine you even need Azle or Express to get this behavior
Locally, all requests to
/api are treated as core IC HTTP protocol requests (see here).
Perhaps this should be reconsidered? It’s going to be extremely common to spin up an Express or other server on ICP and want to create your own /api route at the top level. ICP could name its something uncommon like /_icp_api
ICP could name its something uncommon like /_icp_api
Renaming the core HTTP endpoints of the IC won’t help. That would be a breaking change so the existing naming scheme this endpoint would always need to be maintained anyway.
I think changing the ICX Proxy code to match API requests with
/api/v2/canister/[0-9a-zA-Z\-]+/query should be enough.
ICX Proxy and it’s relationship to DFX is currently being rethought so it’s difficult to say when this change could be made.