I’m curious whether it’s possible to configure an instance of ComposeClient from the @composedb/client library to use a ceramic URL string param that contains a URL prefix after the hostname. For example:
const composeClient = new ComposeClient({
ceramic: 'https://mydomain.io/ceramic',
definition,
});
Given this configuration, I’d then expect ComposeClient to splice the URLs for its API requests relative to this full URL value rather than just the hostname portion. Eg. POST https://mydomain.io/ceramic/api/v0/multiqueries
In my experience ComposeClient only takes the hostname portion of the ceramic param given (https://mydomain.io in my example)
The ability to configure API clients in this way this is essential to anyone who is hosting their web stack behind a reverse proxy and needs to route HTTP requests to various backend services based on the URL path.
I think I understand the positioning here and what you’re trying to achieve. However, before diving any further, wanted to ask how you’ve gone about testing your expectations (that the hostname portion is parsed from the full URL vs. ComposeClient instances accepting and reading a URL in its entirety)? The reason I ask is that I’ve (briefly) gone through the client libraries and checked with some team members, and it sounds like what you’ve described would be a bug (if it is indeed the case), though I have not yet tested it on my end. There may be something I overlooked, so figured it would be more efficient to check with you first
Hey, no problem, happy to elaborate. So I’ve literally ran an experiment similar to the sample code I’ve provided to create a ComposeClient instance, and then used it to run basic queries, such as looking up a document by streamId. In the network tab I’ve observed the URLs of the query requests that my ComposeClient instance produced, and it was consistently stripping off everything after the hostname, then adding its own api/v0/multiqueries bit.
I’ve also looked at your code, and I can see why it’s behaving the way it does in ceramic-http-client.js constructor: https://github.com/ceramicnetwork/js-ceramic/blob/18bb1ce3c61bd05a697099d70d367b3b9df0a80d/packages/http-client/src/ceramic-http-client.ts#L81C1-L81C1
The behaviour of new URI(url, base) is to replace the entire relative URL part of base after the hostname with the new relative URL given (url). See URL: URL() constructor - Web APIs | MDN
@vkuts thank you - this is exactly what I was looking for.
I’d like to loop in @spencer and @ukstv on this thread from the 3Box side.
Also @vkuts - would the following be an accurate brief summary of the need:
Say you have an application hosted on https://example.com - the idea is that you’d want the ability to serve your node endpoint on an extension of the same host (for example, https://example.com/ceramic).