Reputation: 371
Our current Blazor Server project references the Client project, and we would like to decouple them, because we want the controllers to act as a WebAPI - to be used by our Blazor website, mobile apps and also customers wanting to integrate with our system. We have considered splitting the controllers out in a separate service project. Are there any pros or cons to this anyone can think of? And how would you go about doing it?
Edit - this is a WASM solution with Client, Server and Shared projects.
Upvotes: 2
Views: 807
Reputation: 273169
Our current Blazor Server project references the Client project, and we would like to decouple them
The Server does have a project reference to the Client but that is a little trick, it makes MS-Build copy the output of Client to the Server's bin folders. So that the Server can easily 'serve up' the Client. The Server does not call or use any code in the Client.
You could remove the reference and do some configuration with path strings in the Server startup code instead. I don't know the exact details.
So, in accordance with the comment from @MrCakaShaunCurtis, you already have a separate API Server. One that runs on the same URL and port (no CORS issues) and with the small extra job of serving up a bunch of static files that form the Client.
Upvotes: 2