Compare commits

...

2 Commits

Author SHA1 Message Date
9ab29a3a15 Update some packages 2025-04-24 19:07:52 +03:30
6c5fe1bc00 Added cors 2025-04-24 19:07:43 +03:30
3 changed files with 15 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
using CatsOfMastodonBot.Models; using CatsOfMastodonBot.Models;
using CatsOfMastodonBot.Services; using CatsOfMastodonBot.Services;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using mstdnCats.Services; using mstdnCats.Services;
@@ -41,13 +42,23 @@ public class MastodonBot
{ {
options.ListenAnyIP(5005); // Listen on port 5005 options.ListenAnyIP(5005); // Listen on port 5005
}); });
webBuilder.ConfigureServices(services =>
{
services.AddCors(options =>
{
options.AddDefaultPolicy(options =>
{
options.AllowAnyHeader()
.AllowAnyMethod()
.AllowAnyOrigin();
});
});
} );
ServerStartup.Serverstartup(db); ServerStartup.Serverstartup(db);
webBuilder.UseStartup<ServerStartup>(); webBuilder.UseStartup<ServerStartup>();
}) })
.Build(); .Build();
// Setup bot // Setup bot
TelegramBotClient bot; TelegramBotClient bot;
if (!String.IsNullOrEmpty(config.SOCKS_PROXY)) if (!String.IsNullOrEmpty(config.SOCKS_PROXY))

View File

@@ -19,7 +19,7 @@ public class ServerStartup
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
app.UseRouting(); app.UseRouting();
app.UseCors();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapGet("/", async context => endpoints.MapGet("/", async context =>

View File

@@ -11,7 +11,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DotNetEnv" Version="3.1.1" /> <PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="MongoDB.Driver" Version="3.2.1" /> <PackageReference Include="MongoDB.Driver" Version="3.3.0" />
<PackageReference Include="Telegram.Bot" Version="22.4.4" /> <PackageReference Include="Telegram.Bot" Version="22.4.4" />
</ItemGroup> </ItemGroup>