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.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
using skydiveLogs_api.Ioc;
|
using skydiveLogs_api.Ioc;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
@@ -23,12 +24,15 @@ namespace skydiveLogs_api
|
|||||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||||
|
|
||||||
// CORS
|
// CORS
|
||||||
|
var corsConf = Configuration.GetSection("Cors")
|
||||||
|
.GetChildren()
|
||||||
|
.ToDictionary(d => d.Key, d => d.Value);
|
||||||
services.AddCors(options =>
|
services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddDefaultPolicy(
|
options.AddDefaultPolicy(
|
||||||
builder =>
|
builder =>
|
||||||
{
|
{
|
||||||
builder.WithOrigins(Configuration.GetSection("AllowedHosts").Value)
|
builder.WithOrigins(corsConf["FrontUrl"])
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowAnyMethod();
|
.AllowAnyMethod();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning",
|
"Default": "Information",
|
||||||
"System": "Warning",
|
"System": "Information",
|
||||||
"Microsoft": "Warning"
|
"Microsoft": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "http://localhost:4200",
|
"Cors": {
|
||||||
|
"FrontUrl": "http://localhost:4200"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Filename=./Data/JumpsDb.db"
|
"DefaultConnection": "Filename=./Data/JumpsDb.db"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Debug",
|
"Default": "Warning"
|
||||||
"System": "Information",
|
|
||||||
"Microsoft": "Information"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "http://skydivelogsangular.z6.web.core.windows.net",
|
"Cors": {
|
||||||
|
"FrontUrl": "http://skydivelogsangular.z6.web.core.windows.net"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Filename=./Data/JumpsDb.db"
|
"DefaultConnection": "Filename=./Data/JumpsDb.db"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning"
|
"Default": "Debug",
|
||||||
|
"System": "Information",
|
||||||
|
"Microsoft": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "http://localhost:4200",
|
"Cors": {
|
||||||
|
"FrontUrl": "http://localhost:4200"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Filename=./Data/JumpsDb.db"
|
"DefaultConnection": "Filename=./Data/JumpsDb.db"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user