Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use relative URL for the baseURL option #45

Closed
rschristian opened this issue Jul 23, 2020 · 1 comment · Fixed by #51
Closed

Cannot use relative URL for the baseURL option #45

rschristian opened this issue Jul 23, 2020 · 1 comment · Fixed by #51

Comments

@rschristian
Copy link

rschristian commented Jul 23, 2020

(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.

@mfix22
Copy link

mfix22 commented Jul 24, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants