configure grpc client + scanner fixes; need to figure out cors issue
This commit is contained in:
@@ -4,6 +4,21 @@ using AZKiServer.Services;
|
||||
using MongoDB.Driver;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.ConfigureKestrel(o =>
|
||||
{
|
||||
//o.Limits.MaxRequestBodySize = null;
|
||||
#if !DEBUG
|
||||
o.ListenAnyIP(8081, lo =>
|
||||
{
|
||||
lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
|
||||
});
|
||||
o.ListenAnyIP(8080, lo =>
|
||||
{
|
||||
lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2;
|
||||
});
|
||||
#endif
|
||||
});
|
||||
|
||||
var config = builder.Configuration;
|
||||
|
||||
var dbString = config["DB_STRING"];
|
||||
@@ -13,8 +28,8 @@ var db = dbClient.GetDatabase("AZKi");
|
||||
// Add services to the container.
|
||||
builder.Services.AddSingleton(dbClient);
|
||||
builder.Services.AddSingleton<IMongoDatabase>(db);
|
||||
builder.Services.AddGrpc();
|
||||
builder.Services.AddControllers(opt => opt.ModelBinderProviders.Add(new BsonIdModelBinderProvider()));
|
||||
builder.Services.AddGrpc();
|
||||
builder.Services.AddHostedService<FileScannerService>();
|
||||
builder.Services.AddTransient<MediaService>();
|
||||
|
||||
@@ -38,8 +53,20 @@ builder.Services.AddCors(o =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true });
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseCors();
|
||||
|
||||
|
||||
//app.UseAuthentication();
|
||||
//app.UseAuthorization();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
//app.MapGrpcService<GreeterService>();
|
||||
app.MapControllers();
|
||||
app.MapGrpcService<AZKiRpcService>()
|
||||
.AllowAnonymous()
|
||||
.RequireCors("RPC");
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user