Issue
I am deploying a ASP.NET 5, Angular 11, SPA to a network location on a Ubuntu 20.04 local VM. I published the app as linux native self contained. Web API and Client app have same url/port, it's working on dev machine.
I have this in appsettings.json:
"ApplicationUrl": "http://ubuntu1:5000",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://192.168.0.120:5000"
},
}
},
I can see the index.html page with the app loading message but the problem is that the angular part is not starting. Is there some logs I can check somewhere ? The web app itself seems to be working fine, as I tested the web api from Postman.
I have in the .net code:
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
//...
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
Also in /etc/systemd/system/modulo.service on the VM I have:
[Unit]
Description=Modulo ASP .NET Web Application
[Service]
WorkingDirectory=/var/modulo
ExecStart=/var/modulo/Modulo
Restart=always
RestartSec=10
SyslogIdentifier=modulo-app
User=paul (I also tried with www-data)
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
I get no errors when restarting the service on Ubuntu. And the status is active (running).
Solution
It seems I had to also use:
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "ClientApp", "dist")),
RequestPath = ""
});
Answered By - Paul Manson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.