This commit is contained in:
zpc 2025-08-01 14:51:41 +08:00
parent 8926f25ee9
commit aa8a1f9196
3 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
namespace Infrastructure namespace Infrastructure
@ -28,6 +29,7 @@ namespace Infrastructure
.AllowCredentials()//允许cookie .AllowCredentials()//允许cookie
.AllowAnyMethod();//允许任意方法 .AllowAnyMethod();//允许任意方法
}); });
}); });
} }
} }

View File

@ -14,6 +14,7 @@ using ZR.ServiceCore.Signalr;
using ZR.ServiceCore.SqlSugar; using ZR.ServiceCore.SqlSugar;
using ZR.Mall; using ZR.Mall;
using SKIT.FlurlHttpClient.Wechat.Api; using SKIT.FlurlHttpClient.Wechat.Api;
using Infrastructure;
//using SQLitePCL; //using SQLitePCL;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -31,7 +32,9 @@ builder.Services.AddSwaggerGen();
//注入HttpContextAccessor //注入HttpContextAccessor
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// 跨域配置 // 跨域配置
#if DEBUG
builder.Services.AddCors(builder.Configuration); builder.Services.AddCors(builder.Configuration);
#endif
//消除Error unprotecting the session cookie警告 //消除Error unprotecting the session cookie警告
builder.Services.AddDataProtection() builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection")); .PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection"));
@ -155,7 +158,9 @@ app.Use((context, next) =>
app.UseStaticFiles(); app.UseStaticFiles();
//开启路由访问 //开启路由访问
app.UseRouting(); app.UseRouting();
#if DEBUG
app.UseCors("Policy");//要放在app.UseEndpoints前。 app.UseCors("Policy");//要放在app.UseEndpoints前。
#endif
//app.UseHttpsRedirection(); //app.UseHttpsRedirection();
app.UseAuthentication(); app.UseAuthentication();

View File

@ -8,7 +8,7 @@
}, },
"dbConfigs": [ "dbConfigs": [
{ {
"Conn": "Data Source=192.168.1.41;User ID=sa;Password=Dbt@com@123;Initial Catalog=ZrAdmin;Encrypt=True;TrustServerCertificate=True;", "Conn": "Data Source=192.168.195.8;User ID=sa;Password=Dbt@com@123;Initial Catalog=ZrAdmin;Encrypt=True;TrustServerCertificate=True;",
"DbType": 1, // MySql = 0, SqlServer = 1, Oracle = 3PgSql = 4 "DbType": 1, // MySql = 0, SqlServer = 1, Oracle = 3PgSql = 4
"ConfigId": "0", // "ConfigId": "0", //
"IsAutoCloseConnection": true "IsAutoCloseConnection": true
@ -25,12 +25,12 @@
// http://localhost:8888/common/initseedData // http://localhost:8888/common/initseedData
"CodeGenDbConfig": { "CodeGenDbConfig": {
//{dbName} //{dbName}
"Conn": "Data Source=192.168.1.41;User ID=sa;Password=Dbt@com@123;Encrypt=True;TrustServerCertificate=True;Initial Catalog={dbName};", "Conn": "Data Source=192.168.195.8;User ID=sa;Password=Dbt@com@123;Encrypt=True;TrustServerCertificate=True;Initial Catalog={dbName};",
"DbType": 1, "DbType": 1,
"IsAutoCloseConnection": true, "IsAutoCloseConnection": true,
"DbName": "ZrAdmin" //,Oracle "DbName": "ZrAdmin" //,Oracle
}, },
"urls": "http://localhost:8888", //urldevServer "urls": "http://*:8888", //urldevServer
"corsUrls": [ "http://localhost:8887", "http://localhost:8886" ], //"," "corsUrls": [ "http://localhost:8887", "http://localhost:8886" ], //","
"JwtSettings": { "JwtSettings": {
"Issuer": "ZRAdmin.NET", //token "Issuer": "ZRAdmin.NET", //token