Configuring ComposeClient with a ceramic URL string that contains a prefix

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: '',

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
In my experience ComposeClient only takes the hostname portion of the ceramic param given ( 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.

Hello @vkuts ! Thanks for the forum post.

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:
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 - the idea is that you’d want the ability to serve your node endpoint on an extension of the same host (for example,

Thanks again!

Yes exactly right @mzk . I want to be able to query my Ceramic node’s API at as opposed to or some other dedicated port.

Thanks for letting us know about this issue! I have filed a ticket for the development team to fix this bug.

1 Like

@vkuts just keeping you in the loop: Patch for http-client URL constructor by mzkrasner · Pull Request #3012 · ceramicnetwork/js-ceramic · GitHub

Will let you know once it’s merged

@vkuts this has been merged: Patch for http-client URL constructor by mzkrasner · Pull Request #3012 · ceramicnetwork/js-ceramic · GitHub

In terms of timing between now and full release, i’d anticipate between 1-2 weeks