Relative path for axios url request requires a '/' prefix for local but not hosted server

Not sure if this is an axios issue or not, but this works for me locally:

axios('/api/test').then(response => console.log(

But on my hosted server, it requires this:

axios('api/test').then(response => console.log(

Notice that the url request prefix '/' is there for local and not for server.

Is there any way to handle this (maybe Laravel Mix?) without doing something like this hack:

var p = location.hostname === "localhost" || location.hostname === "" ? '/' : ''
axios(p + 'api/test').then(response => console.log(

I'm using Laravel(5.8)/Vue with the standard folder structure. The request route above is:

Route::get('test', 'TestController@index');

and located in the AppName/routes/api.php file.