Cannot use relative URL for the baseURL option
rschristian opened this issue · 1 comments
(Using Preact-CLI's issue template as I find it easy to read)
Do you want to request a feature or report a bug?
Likely a bug
What is the current behavior?
Currently Redaxios cannot use relative URLs for its baseURL
. The URL()
constructor, if passed a base
parameter, needs that parameter to be a valid URL on its own, and a relative URL like /api/
is not. MDN Docs.
If the current behaviour is a bug, please provide the steps to reproduce.
Simply open a browser console and write:
new URL('foo', '/api/');
You will get an error stating the following:
Uncaught TypeError: URL constructor: /foo/ is not a valid URL.
That example is how Redaxios currently forms its URLs when a baseURL
is supplied
What is the expected behaviour?
I'd like to be able to use relative URLs for the base as they're very handy for proxying front-end applications.
If it helps, this PR reproduces the issue: carbon-app/carbon#1054 (just open the "Background Image" menu w/ a debug point set in the redaxios
try/catch)