1

I'm trying to read cookies from the controller in the api rest saved from a SPA Middleware

I have 2 SPA projects (www.spa1.com, www.spa2.com) and one for the rest (api.spa1.com, api.spa2.com). I'm trying to read cookies from the controller in the api rest saved from a SPA Middleware

SPA Middleware:
        private void AddCookie(HttpContext context, string key, string value)
        {
            context.Response.Cookies.Append(key, value,
                new CookieOptions
                {
                    Path = "/",
                    Domain = context.Request.Host.Host,
                    HttpOnly = true,
                    Secure = true,
                    Expires = DateTimeOffset.Now.AddMonths(3),
                    SameSite = SameSiteMode.None
                });
        }

API controller

Jorgelig
  • 184
  • 2
  • 9
  • 1
    It's called cross-domain cookie sharing, if you want you can read about it here: https://stackoverflow.com/questions/3342140/cross-domain-cookies. Since a cookie is tied to it's domain you need to create cookies on the same domain. – Iaroslav Jul 01 '19 at 18:41
  • Cookies are saved and read from applications in the same domain, for example: www.spa1.com and api.spa1.com. – Jorgelig Jul 01 '19 at 19:03

0 Answers0