~furry/mamoru-server

9953e6444a95944913d52fb093cf5addf38c4b58 — nora 2 months ago 901ce1d
fix cors header on req
1 files changed, 8 insertions(+), 0 deletions(-)

M Utils/AbstractRoute.cs
M Utils/AbstractRoute.cs => Utils/AbstractRoute.cs +8 -0
@@ 23,6 23,14 @@ public abstract class AbstractRoute {
  }

  public virtual void Options(ref HttpListenerRequest req, ref HttpListenerResponse res) {
    if (Cors) {
      res.Headers.Add("Access-Control-Allow-Origin", "*");
      res.Headers.Add("Access-Control-Allow-Headers", "*");
      res.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
      res.Headers.Add("Access-Control-Max-Age", "86400");
      EmptyResponse.Create(ref res);
      return;
    }
    EmptyResponse.Create(ref res, HttpStatusCode.MethodNotAllowed);
  }