But shouldn’t I be able to point to different services? I would expect the BaseUrl that’s mentioned in each of the dtos files to be used, but it’s not. Having a single global BaseUrl doesn’t make sense in this case to me. And isn’t that for the web app itself?
Web app will be on 8080 for example, and API may be on 5001, for example or even a different host using CORS.
No it always uses the website that the App is loaded from, otherwise you’d need to enable CORS.
If you want to use a different URL you will need to configure the full BaseUrl in the JsonServiceClient, and then will need to configure CORS to allow cross-domain requests.
The BaseUrl is where the DTO types are updated from, the URL is not embedded in any DTOs. The URL used is always what the JsonServiceClient is configured with, which by default is / so it uses the same URL as the App, which is nearly always what you want.
But isn’t it quite common to be able to specify any host name to access an API from within a website? I know you can do this using raw Vue stuff like Axios or the fetch api. So are you saying that with ServiceStack, I only get ONE global url to call an api via JsonServiceClient?
No it’s not common to have APIs on a different domain, otherwise every web server would need to have CORS enabled. That’s not normal, it’s only required when the Web App and APIs are hosted on different domains.
No I’ve never said anything close to that. You can use as many different JsonServiceClient as you want:
var client1 = new JsonServiceClient(BaseUrl1);
var client2 = new JsonServiceClient(BaseUrl2);