算神 3 年之前
父節點
當前提交
fd4d485bdb
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. +9
    -0
      src/JT808.Gateway/JT808HttpServer.cs

+ 9
- 0
src/JT808.Gateway/JT808HttpServer.cs 查看文件

@@ -76,6 +76,15 @@ namespace JT808.Gateway
context.Http404();
continue;
}
// 增加CORS
// https://stackoverflow.com/questions/25437405/cors-access-for-httplistener
if (context.Request.HttpMethod == HttpMethod.Options.Method)
{
context.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With");
context.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
context.Response.AddHeader("Access-Control-Max-Age", "1728000");
}
context.Response.AppendHeader("Access-Control-Allow-Origin", "*");
if (authorization.Authorization(context, out var principal))
{
await ProcessRequestAsync(context, principal);


Loading…
取消
儲存