Closed colearendt closed 1 year ago
Yes, we should document that it's meant to accept absolute URLs. The fact that it uses WHATWG URL is an implementation detail - I don't think we should expose that (we previously used superagent).
The workaround is inconvenient, but I don't think it's worth adding the relative URL handling right now (unless maybe if WHATWG URL supports relative URL w/o base OOTB).
Feature request
Is your feature request related to a problem? Please describe.
To make deployment of my application "simpler," I have a proxy that listens on the same domain as the domain the UI is served from. (i.e.
__api__/
gets sent to my PostgREST API, everything else goes to the frontend)However, referring to this API in PostgrestClient with a relative path throws an error
From here: https://github.com/supabase/postgrest-js/blob/aa223b4569b5c08714bb1d029e8f780e19db2b09/src/lib/PostgrestQueryBuilder.ts#L14
Contrasting this with
axios
, for instance, which takes a relative URL just fine.Describe the solution you'd like
It would be ideal to be a bit more flexible in how URLs are taken / used so that relative paths can be used
Describe alternatives you've considered
At a minimum, better documentation and logging on the requirements for
url
(even just documenting that it will get passed tonew URL()
would be helpful).The solution/workaround is to generate the absolute URL reference. In my case:
This is much less than ideal because I have to track a separate URL for the PostgrestClient than for my other API client libraries (and the application is hosted at different schemes, potentially at different root paths, etc.).
Additional context