Skip to main content

baseUrl

  • baseUrl will prepend the given url. unless url is absolute or URL object.


note

http-pro is has no opinion about leading slash in input URL or trailing slash in baseUrl, because it will remove slash if Input starts with slash, and it will add slash at the end of the baseUrl if there is no slash. because of this feature following input and baseUrl will resolve to same url.

hp.get('/api/me', { baseUrl: 'https://wwww.google.com' }); // https://wwww.google.com/api/me
hp.get('api/me', { baseUrl: 'https://wwww.google.com/' }); // https://wwww.google.com/api/me
hp.get('/api/me', { baseUrl: 'https://wwww.google.com/' }); // https://wwww.google.com/api/me
hp.get('api/me', { baseUrl: 'https://wwww.google.com/' }); // https://wwww.google.com/api/me
hp.get('api/me', { baseUrl: 'https://wwww.google.com' }); // https://wwww.google.com/api/me