-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathProgram.cs
More file actions
27 lines (23 loc) · 826 Bytes
/
Program.cs
File metadata and controls
27 lines (23 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
//Add headers to prevent errors
app.Use(async (context, next) =>
{
context.Response.Headers["Cross-Origin-Opener-Policy"] = "same-origin";
context.Response.Headers["Cross-Origin-Embedder-Policy"] = "require-corp";
await next();
});
var staticPath = Path.Combine(Directory.GetCurrentDirectory(), "public");
app.UseDefaultFiles(new DefaultFilesOptions
{
FileProvider = new PhysicalFileProvider(staticPath),
DefaultFileNames = new[] { "index.html" }
});
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(staticPath)
});
app.Run("http://0.0.0.0:80");