Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yevon opened this issue Nov 10, 2024 · 2 comments
Labels

Comments

@yevon
Copy link

yevon commented Nov 10, 2024

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);
@yevon yevon added the bug label Nov 10, 2024
@yevon yevon changed the title [fix] SuperTest agents does support multiple cookies persist and cookie parser? [fix] SuperTest agents does support multiple cookies persist and cookie parser? HttpOnly cookies? Nov 10, 2024
@yevon
Copy link
Author

yevon commented Nov 10, 2024

It seems that it was due to using localhost as the domain for cookies, it should be 127.0.0.1 in order to make it to work. It was working with the browser, so I was wondering if the agents should support "localhost" as domain or not.

@yevon yevon changed the title [fix] SuperTest agents does support multiple cookies persist and cookie parser? HttpOnly cookies? [fix] SuperTest agents does support multiple cookies persist and cookie parser? Localhost domain cookies Nov 10, 2024
@yevon yevon changed the title [fix] SuperTest agents does support multiple cookies persist and cookie parser? Localhost domain cookies [fix] SuperTest agents not sending cookies for Localhost domain cookies, you must set them to 127.0.0.1 Nov 11, 2024
@yevon
Copy link
Author

yevon commented Nov 11, 2024

This issue is related to ladjs/superagent then or to supertest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant