Django REST Framework - cookie 未通过 Response.set_cookie() 调用设置...?

Django REST Framework - cookies not being set via Response.set_cookie() call...?

我的 DRF 应用程序中有以下标准响应设置:

response = Response(data=response, status=status.HTTP_200_OK)

然后我尝试通过 response.set_cookie() 调用将拆分 JWT header.payloadsignature 添加到响应 headers 中,如下所示:

        max_age = 365 * 24 * 60 * 60

        expires = datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age)

        response.set_cookie(
            key='JWT_ACCESS_HEADER_PAYLOAD',
            value=header_payload,
            httponly=False,
            expires=expires.strftime("%a, %d-%b-%Y %H:%M:%S UTC"),
            max_age=max_age
        )

        response.set_cookie(
            key='JWT_ACCESS_SIGNATURE',
            value=signature,
            httponly=True,
            expires=expires.strftime("%a, %d-%b-%Y %H:%M:%S UTC"),
            max_age=max_age
        )

        return response

到目前为止,我看不出有什么问题:

然而,由于某些原因,唯一在客户端设置的cookie如下:

我哪里做错了??

headers 中的实际输出似乎是一个有效的 SetCookie 值:

JWT_ACCESS_HEADER_PAYLOAD=aSasas; expires=Sat, 03-Apr-2021 10:24:31 GMT; Max-Age=31536000; Path=/

JWT_ACCESS_SIGNATURE=asaSasaS; expires=Sat, 03-Apr-2021 10:24:31 GMT; HttpOnly; Max-Age=31536000; Path=

N.B。 运行 在本地主机上...是否有帮助?

所以,这似乎是一个非常微不足道的解决方案,因为它就是这样。

我正在使用 axios ... 没有发送 { withCredentials: true } 请求。

正在设置 cookie - 因为,嗯,它们是。只是为了看到它们我需要刷新浏览器。