diff --git a/.gitignore b/.gitignore index 5dcad6f..eb5b9d7 100644 --- a/.gitignore +++ b/.gitignore @@ -35,8 +35,8 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ +# Frontend build output +wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ diff --git a/.idea/.idea.4Gewinnt/.idea/workspace.xml b/.idea/.idea.4Gewinnt/.idea/workspace.xml index b8d815e..1ee19a8 100644 --- a/.idea/.idea.4Gewinnt/.idea/workspace.xml +++ b/.idea/.idea.4Gewinnt/.idea/workspace.xml @@ -9,9 +9,9 @@ - - - + + + @@ -158,7 +166,8 @@ diff --git a/API/Controllers/StatusController.cs b/API/Controllers/StatusController.cs index 18b8f67..1a3ccf5 100644 --- a/API/Controllers/StatusController.cs +++ b/API/Controllers/StatusController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc; namespace API.Controllers; [ApiController] -[Route("[controller]")] +[Route("api/[controller]")] public class StatusController : ControllerBase { [HttpGet] diff --git a/API/Program.cs b/API/Program.cs index 8e67c3f..89f4084 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -1,8 +1,15 @@ var builder = WebApplication.CreateBuilder(args); +// Serve frontend from wwwroot at solution root +var webRootPath = Path.GetFullPath(Path.Combine(builder.Environment.ContentRootPath, "..", "wwwroot")); +Directory.CreateDirectory(webRootPath); +builder.Environment.WebRootPath = webRootPath; +builder.WebHost.UseWebRoot(webRootPath); + // Add services to the container. builder.Services.AddControllers(); +builder.Services.AddSignalR(); builder.Services.AddOpenApi(); builder.Services.AddSwaggerGen(); @@ -18,8 +25,14 @@ if (app.Environment.IsDevelopment()) app.UseHttpsRedirection(); +app.UseStaticFiles(); + app.UseAuthorization(); app.MapControllers(); +app.MapHub("/api/game"); + +// SPA fallback: serve index.html for routes not matched by API or static files +app.MapFallbackToFile("index.html"); app.Run(); diff --git a/GUI/vite.config.ts b/GUI/vite.config.ts index 4217010..eb55360 100644 --- a/GUI/vite.config.ts +++ b/GUI/vite.config.ts @@ -15,4 +15,8 @@ export default defineConfig({ '@': fileURLToPath(new URL('./src', import.meta.url)) }, }, + build: { + outDir: '../wwwroot', + emptyOutDir: true, + }, })