繁体   English   中英

在 axios 中设置身份 cookie

[英]Set identity cookie in axios

我已经设置了一个具有核心身份的项目并通过我的端点成功注册了用户,但我无法将声明主体获取到我的客户端浏览器。

使用邮递员发帖:

https://localhost:7273/signin?username=test&password=Test123!

然后我可以在邮递员中执行以下操作

https://localhost:7273/getuserinfo

从 cookie 中成功获取我的用户声明并检索用户信息。

但是,当我使用 axios 在我的 nuxt 应用程序中执行相同的请求时,没有设置任何 cookie,并且我的 response.headers 未定义。

const res = await this.$axios.$post("https://localhost:7273/signin", {}, { params : {username : "test", password: "Test123!"}}, 
{withCredentials: true}).then(function(response) { 
    console.log({ headers: response.headers 
    });
});

在我的后端,我得到 signinResult = succeeded

    [Route("Signin")]
    [HttpPost]
    public async Task<IActionResult> Signin(string username, string password)
    {
        var signinResult = await _signinManager.PasswordSignInAsync(username, password, true, false);
        var principal = HttpContext.User as ClaimsPrincipal;
        return Ok();
    }

我缺少什么链接可以在邮递员中进行这项工作,但在我的 web 应用程序中却没有?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM