I am running a REST server on http://localhost:8080, my Aurelia app on http://localhost:9000 and want to access the server with aurelia-fetch-client. I fail miserably already with the URL: For reasons I don't understand, the Aurelia host:port combination gets prefixed. The request URL turns out to be:
http://localhost:9000/localhost:8080/restapi/v1/things
But obviously I want:
http://localhost:8080/restapi/v1/things
Configuration:
let httpClient = new HttpClient();
httpClient.configure(config => {
config
.withBaseUrl('http:/localhost:8080/restapi/v1/')
.withDefaults({
credentials: 'omit',
mode: 'cors',
});
});
Call:
return httpClient
.fetch('things', {
method: 'get'
})
...
I have expected to run into all kind of CORS trouble, but that I cannot even get the URL right is a bit disappointing :-)
Does anybody see what I am doing wrong?
Ideally I would like to bypass CORS completely, i.e. not having to enable the REST server for CORS. But at this point I'd already be happy if the URL came out right.