davidfowl / Micronetes

Micronetes is a local orchestrator inspired by kubernetes that makes developing and testing microservices and distributed applications easier.
MIT License
773 stars 46 forks source link

Add a CORS policy to MicronetesHost #55

Closed alexfdezsauco closed 4 years ago

alexfdezsauco commented 4 years ago

Add a CORS policy to MicronetesHost to allow discover backend service endpoints from a web frontend like a blazor webassembly or any javascript single page application.

In Blorc.Core we have a configuration service that read values from configuration files that could be hosted in the web server.

image

micronetes.development.json

{
  "Url": "http://127.0.0.1:8001"
}

We can specify the environment file with a parameter in the Url. In this case http://localhost:5005?env=development

image

So, the Program entry point could look like this:

        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("app");

        builder.Services.AddBlorcCore();
        if (await builder.IsMicronetesConfigurationAvailable())
        {
            builder.Services.AddSingleton<IServiceDiscovery, MicronetesServiceDiscovery>();
        }

where could be possible use an implementation of IServiceDiscovery for Micronetes, to help connect client side with server side when the APIs are hosted in Micronetes. The MicronetesServiceDiscovery is a work in progress and should be available soon as part of Blorc.Core (or as isolate package).

I use this approach for apps hosted in DCOS (Marathon) with a MarathonServiceDiscovery. But now is possible deploy and debug distributed service locally with Micronetes, so query the available endpoints from the client apps for development purpose could be a good idea.

alexfdezsauco commented 4 years ago

Not sure why CI is failing.

davidfowl commented 4 years ago

Hey, @alexfdezsauco all progress will be moving to https://github.com/dotnet/tye. It would be great to move this over here

alexfdezsauco commented 4 years ago

Thanks, I will.