Fix the setting aboout Cors url
This commit is contained in:
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Linq;
|
||||
|
||||
using skydiveLogs_api.Ioc;
|
||||
using AutoMapper;
|
||||
@@ -23,12 +24,15 @@ namespace skydiveLogs_api
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
|
||||
// CORS
|
||||
var corsConf = Configuration.GetSection("Cors")
|
||||
.GetChildren()
|
||||
.ToDictionary(d => d.Key, d => d.Value);
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(
|
||||
builder =>
|
||||
{
|
||||
builder.WithOrigins(Configuration.GetSection("AllowedHosts").Value)
|
||||
builder.WithOrigins(corsConf["FrontUrl"])
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user