Prechádzať zdrojové kódy

启动url设置为全局开放

lcl 8 mesiacov pred
rodič
commit
ef8c41b8f0

+ 3 - 3
Middleware/GlobalExceptionMiddleware.cs

@@ -35,9 +35,9 @@ namespace Middleware
             try
             {
                 // 设置允许跨域的域名、方法等
-                context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
-                context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
-                context.Response.Headers.Add("Access-Control-Allow-Headers", "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization");
+                // context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
+                // context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
+                // context.Response.Headers.Add("Access-Control-Allow-Headers", "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization");
 
                 // 如果请求方法是预检请求(OPTIONS),则直接返回成功状态码
                 if (context.Request.Method == "OPTIONS")

+ 1 - 1
Program.cs

@@ -25,7 +25,7 @@ builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
 // builder.Services.AddIPRate(builder.Configuration);
 builder.Services.AddSession();
 builder.Services.AddHttpContextAccessor();
-builder.Services.AddCors(option => option.AddPolicy("cors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().SetIsOriginAllowed(_ => true)));
+// builder.Services.AddCors(option => option.AddPolicy("cors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().SetIsOriginAllowed(_ => true)));
 builder.Services.Configure<KestrelServerOptions>(x => x.AllowSynchronousIO = true).Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
 
 //绑定整个对象到Model上

+ 3 - 3
Properties/launchSettings.json

@@ -4,7 +4,7 @@
     "windowsAuthentication": false,
     "anonymousAuthentication": true,
     "iisExpress": {
-      "applicationUrl": "http://localhost:49293",
+      "applicationUrl": "http://*:49293",
       "sslPort": 44376
     }
   },
@@ -14,7 +14,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://localhost:5296",
+      "applicationUrl": "http://*:5296",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
@@ -24,7 +24,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://localhost:5296",
+      "applicationUrl": "http://*:5296",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }