From b3d339d7fb64a3b6a7aae01e938ecf73e5adcdae Mon Sep 17 00:00:00 2001 From: MahanCh Date: Mon, 7 Jul 2025 13:01:50 +0330 Subject: [PATCH] set cookie domain --- ServiceHost/Program.cs | 12 +++++++++--- ServiceHost/appsettings.Development.json | 7 +++++-- ServiceHost/appsettings.json | 5 ++++- ServiceHost/web.config | 10 ++++++---- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ServiceHost/Program.cs b/ServiceHost/Program.cs index 43a0cdfd..939f07b6 100644 --- a/ServiceHost/Program.cs +++ b/ServiceHost/Program.cs @@ -94,14 +94,14 @@ builder.Services.Configure(options => options.CheckConsentNeeded = context => true; //options.MinimumSameSitePolicy = SameSiteMode.Strict; }); - +var cookieDomain = builder.Configuration["CookieSettings:Domain"]; builder.Services.ConfigureApplicationCookie(options => { //options.Cookie.Name = "GozarAuth"; options.Cookie.HttpOnly = true; options.Cookie.SameSite = SameSiteMode.None; // مهم ✅ options.Cookie.SecurePolicy = CookieSecurePolicy.Always; // فقط روی HTTPS کار می‌کنه ✅ - options.Cookie.Domain = ".dad-mehr.ir"; // دامنه مشترک بین پدر و ساب‌دامین‌ها ✅ + options.Cookie.Domain = cookieDomain; // دامنه مشترک بین پدر و ساب‌دامین‌ها ✅ }); @@ -263,7 +263,13 @@ builder.Services.AddCors(options => "https://gozareshgir.ir", "https://dad-mehr.ir", "https://admin.dad-mehr.ir", - "https://admin.gozareshgir.ir" + "https://admin.gozareshgir.ir", + "https://api.local.dad-mehr.ir", + "https://local.dad-mehr.ir", + "https://localhost:7080", + "https://api.local.dad-mehr.ir:7080" + //"http://localhost:3001", + ) .AllowAnyHeader() .AllowAnyMethod() diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json index 909ff3cd..5a01248e 100644 --- a/ServiceHost/appsettings.Development.json +++ b/ServiceHost/appsettings.Development.json @@ -13,7 +13,7 @@ //server //"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;", - + //local "MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;", @@ -31,7 +31,10 @@ "SmsSecrets": { "ApiKey": "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa", "SecretKey": "dadmehr" + }, + "CookieSettings": { + "Domain": ".local.dad-mehr.ir" } -} +} diff --git a/ServiceHost/appsettings.json b/ServiceHost/appsettings.json index b5c17e38..4e8374d5 100644 --- a/ServiceHost/appsettings.json +++ b/ServiceHost/appsettings.json @@ -22,5 +22,8 @@ "faceModels": { "Faces": "c://labels//20//" }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "CookieSettings": { + "Domain": ".dad-mehr.ir" + } } diff --git a/ServiceHost/web.config b/ServiceHost/web.config index 82d5b955..d982bbfb 100644 --- a/ServiceHost/web.config +++ b/ServiceHost/web.config @@ -5,8 +5,11 @@ - - + + + + + @@ -15,5 +18,4 @@ - - + \ No newline at end of file