diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e855a50..742ac3b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,6 @@ stages: # Define the stages of the pipeline. web-build: # This job runs in the build stage, which runs first. stage: build image: node:24 - parallel: 2 script: - cd Web - npm install @@ -22,7 +21,6 @@ web-build: # This job runs in the build stage, which runs first. api-build: stage: build image: mcr.microsoft.com/dotnet/sdk:8.0 - parallel: 2 script: - cd Api - dotnet publish Api.csproj --output ./build --runtime linux-x64 --configuration Release --self-contained true diff --git a/Api/.gitignore b/Api/.gitignore index b7ccb59..cee7699 100644 --- a/Api/.gitignore +++ b/Api/.gitignore @@ -1,4 +1,5 @@ obj/ bin/ .vs/ -build/ \ No newline at end of file +build/ +**/core \ No newline at end of file diff --git a/Api/Program.cs b/Api/Program.cs index 4827860..33ff6a9 100644 --- a/Api/Program.cs +++ b/Api/Program.cs @@ -56,6 +56,51 @@ namespace Api app.UseHttpsRedirection(); } + if (app.Environment.IsDevelopment()) + { + var staticFilePath = "/workspaces/centrum/Web/dist/Web/browser"; + app.UseDefaultFiles(new DefaultFilesOptions + { + FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(staticFilePath), + DefaultFileNames = new List { "index.html" } + }); + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(staticFilePath), + RequestPath = "" + }); + // Angular routing fallback + app.Use(async (context, next) => + { + await next(); + var path = context.Request.Path.Value ?? string.Empty; + if (context.Response.StatusCode == 404 && + !System.IO.Path.HasExtension(path) && + !path.StartsWith("/api")) + { + context.Request.Path = "/index.html"; + await next(); + } + }); + } + else + { + app.UseDefaultFiles(); // Uses wwwroot by default + app.UseStaticFiles(); + // Angular routing fallback for production + app.Use(async (context, next) => + { + await next(); + var path = context.Request.Path.Value ?? string.Empty; + if (context.Response.StatusCode == 404 && + !System.IO.Path.HasExtension(path) && + !path.StartsWith("/api")) + { + context.Request.Path = "/index.html"; + await next(); + } + }); + } app.UseAuthentication(); app.UseAuthorization(); diff --git a/Api/core b/Api/core deleted file mode 100644 index e10e7da..0000000 Binary files a/Api/core and /dev/null differ