mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
allow all cross domain requests (#28)
This commit is contained in:
@@ -6,10 +6,11 @@ using EggLink.DanhengServer.WebServer.Objects;
|
||||
using Google.Protobuf;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
namespace EggLink.DanhengServer.WebServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[EnableCors("AllowAll")]
|
||||
[Route("/")]
|
||||
public class DispatchRoutes
|
||||
{
|
||||
|
||||
@@ -4,9 +4,11 @@ using EggLink.DanhengServer.WebServer.Response;
|
||||
using EggLink.DanhengServer.WebServer.Server;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
namespace EggLink.DanhengServer.WebServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[EnableCors("AllowAll")]
|
||||
[Route("/")]
|
||||
public class MuipServerRoutes
|
||||
{
|
||||
|
||||
@@ -4,6 +4,12 @@ using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.IO;
|
||||
|
||||
namespace EggLink.DanhengServer.WebServer
|
||||
{
|
||||
@@ -46,6 +52,17 @@ namespace EggLink.DanhengServer.WebServer
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll",
|
||||
builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
@@ -76,6 +93,8 @@ namespace EggLink.DanhengServer.WebServer
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
|
||||
Reference in New Issue
Block a user