Skip to content

[fix] SuperTest agents not sending cookies for Localhost domain cookies, you must set them to 127.0.0.1 #847

@yevon

Description

@yevon

I'm unable to have the agent to automatically send my cookies to my requests after a successful login. What I don't undersand is that if try to set the cookies manually reading them from the agent itself it just works, but if i just remove the .set("Cookie") it stops working immediately. In my node express application, the very first thing I do is to setup cookieParser. It seems similar to the provided example on agents and cookies. The cookies are set as insecure already. Does the httpOnly flag of the cookies affect to this?

const app: Express = express();
app.use(cookieParser());
const response: Response = await myAgent.post("/post")
   .field("description", "This is a test post.")
   .field("price", "100")
   .set(
     "Cookie",
     myAgent.jar.getCookies({
         domain: "localhost",
         path: "/",
         secure: false,
         script: false,
       })
       .at(0)!
       .toString()
   )
   .redirects(5);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions