Skip to content

Instantly share code, notes, and snippets.

@neon-sunset
Last active February 13, 2023 22:34
Show Gist options
  • Save neon-sunset/40edae0c10268440fcdb64d050afc1c2 to your computer and use it in GitHub Desktop.
Save neon-sunset/40edae0c10268440fcdb64d050afc1c2 to your computer and use it in GitHub Desktop.
using Microsoft.AspNetCore.StaticFiles.Infrastructure;
using Microsoft.Extensions.FileProviders;
var builder = WebApplication.CreateBuilder(args);
// builder.Logging.SetMinimumLevel(LogLevel.Warning);
builder.Services
.AddAntiforgery()
.AddResponseCompression();
var host = builder.Build();
var contentOptions = new SharedOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(host.Environment.ContentRootPath, "../web/dist/"))
};
host.UseResponseCompression()
.UseDefaultFiles(new DefaultFilesOptions(contentOptions))
.UseStaticFiles(new StaticFileOptions(contentOptions));
host.Run("http://+:8080");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment