From 81b7bd3fe05057b90267b2d7e7a6651187ec9198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=98=89=E7=A5=A5=20=E8=A9=B9?= Date: Fri, 22 Mar 2024 11:40:14 +0800 Subject: [PATCH] updates --- Controllers/ApiController.cs | 3 +- Program.cs | 79 ++++++++++++------- appsettings.json | 2 +- .../assets/javascript/custom/newslist.js | 4 +- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/Controllers/ApiController.cs b/Controllers/ApiController.cs index 522539b..031f100 100644 --- a/Controllers/ApiController.cs +++ b/Controllers/ApiController.cs @@ -77,7 +77,8 @@ namespace Bremen_ESG.Controllers return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); } - [HttpPost] + + [Route("esg_message")] public async Task Esg_Message(IFormCollection obj) { result ret = new result(); diff --git a/Program.cs b/Program.cs index a2c9003..1b26ae4 100644 --- a/Program.cs +++ b/Program.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -6,38 +7,59 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddCors(options => { - options.AddDefaultPolicy(builder => - { - - - + options.AddDefaultPolicy( + policy => + { + policy.WithOrigins("http://www.bremen.com.tw", + "http://bremen.com.tw", + "https://www.bremen.com.tw", + "https://bremen.com.tw", + "http://preview.bremen.com.tw", + "https://preview.bremen.com.tw" + ).AllowAnyMethod().AllowAnyHeader(); + }); +}); - /* - builder - .WithOrigins("https://*.bremen.com.tw", - "https://localhost:7245", - "https://bremen.com.tw") - .AllowAnyMethod() - .AllowAnyHeader(); - */ - - builder - .WithOrigins(GlobalClass.appsettings("CorsOrigins") - .Split(",", StringSplitOptions.RemoveEmptyEntries) - .ToArray() ?? Array.Empty()) - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyMethod() - .AllowAnyHeader(); - +//builder.Services.AddCors(options => +//{ +// options.AddDefaultPolicy(builder => +// { - }); + + + + +// builder +// .WithOrigins("https://*.bremen.com.tw", +// "https://localhost:7245", +// "https://bremen.com.tw") +// .AllowAnyMethod() +// .AllowAnyHeader(); + + +// // builder +// //.WithOrigins(GlobalClass.appsettings("CorsOrigins") +// //.Split(",", StringSplitOptions.RemoveEmptyEntries) +// //.ToArray() ?? Array.Empty()) +// //.SetIsOriginAllowedToAllowWildcardSubdomains() +// //.AllowAnyMethod() +// //.AllowAnyHeader(); + + +// }); +//}); + +builder.Services.AddCors(options => +{ + options.AddPolicy("AllowAll", builder => + builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader()); }); // Add services to the container. builder.Services.AddControllersWithViews(); - -// Add services to the container. -builder.Services.AddControllersWithViews(); +builder.Services.AddControllers(); builder.Services.TryAddSingleton(); @@ -56,12 +78,13 @@ defaultFilesOptions.DefaultFileNames.Clear(); defaultFilesOptions.DefaultFileNames.Add("index.html"); defaultFilesOptions.DefaultFileNames.Add("iisstart.htm"); app.UseDefaultFiles(defaultFilesOptions); -app.UseCors(); + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); - +app.UseCors("AllowAll"); +//app.UseCors(); app.UseAuthorization(); app.MapControllerRoute( diff --git a/appsettings.json b/appsettings.json index e157b3f..0e4b0ec 100644 --- a/appsettings.json +++ b/appsettings.json @@ -21,5 +21,5 @@ "sender_email": "bremen@bremen.com.tw", "sender_name": "ESG需求聯絡表通知信" }, - "CorsOrigins": "https://*.bremen.com.tw,https://localhost:7245,https://bremen.com.tw" + "CorsOrigins": "https://*.bremen.com.tw,https://localhost:7245,https://bremen.com.tw,https://preview.bremen.com.tw" } diff --git a/wwwroot/BackEnd/assets/javascript/custom/newslist.js b/wwwroot/BackEnd/assets/javascript/custom/newslist.js index 2321d4c..a8adc89 100644 --- a/wwwroot/BackEnd/assets/javascript/custom/newslist.js +++ b/wwwroot/BackEnd/assets/javascript/custom/newslist.js @@ -671,11 +671,9 @@ function initSummernote() { // [groupName, [list of button]] ['style', ['bold', 'italic', 'underline', 'clear']], ['font', ['strikethrough', 'superscript', 'subscript']], - ['fontsize', ['fontsize']], ['color', ['color']], ['insert', ['link']], - ['para', ['ul', 'ol', 'paragraph']], - ['height', ['height']] + ['para', ['ul', 'paragraph']] ] }); } \ No newline at end of file