dgtlmoon / dgtlmoon/changedetection.io

'Cookie:' header dissapears on redirect

Open
#3,292 2 comments 0 reactions 1 assignee Claimed by @dgtlmoon View on GitHub
triage upstream-bug
Dominant language
Python
Stars
34.1k
Forks
2k
Avg merge
22h 52m
Merged PRs (30d)
70

Description

**Describe the bug**
Had a watch start failing recently due to being logged out. The only change was the page now redirects to a different page. I double checked the request in mitmproxy and the original request includes my cookie header, but the request following the redirect doesn't have the cookie header.

**Version**
v0.50.5

**How did you install?**
docker compose

**To Reproduce**

Steps to reproduce the behavior:
1. Create a watch
- Url: https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org/cookies
- Fetch method: 'Basic fast Plaintext/HTTP Client'
- Advanced options -> Request headers: `Cookie: examplecookie=3`

**Expected behavior**
Cookie header is sent with both the initial request and redirected request

I'd expect to see my cookies:

![Image](https://github.com/user-attachments/assets/d6880121-c9c7-4846-8269-c9f4e3f1b984)

But instead they're missing:

![Image](https://github.com/user-attachments/assets/d1fb5a24-43c0-4e5e-b74e-e20024eb0be6)

**Screenshots**

![Image](https://github.com/user-attachments/assets/7908cf0d-888d-4355-bdd4-f83f7a6f4473)

![Image](https://github.com/user-attachments/assets/3ce73901-c39f-4bb9-8fc8-2d2e5282f351)

**Additional context**
Dug in a bit and found that `requests` drops manually-set cookie headers when following a redirect in a session (https://github.com/psf/requests/blob/91a3eabd3dcc4d7f36dd8249e4777a90ef9b4305/src/requests/sessions.py#L235)
It doesn't look like they're interested in changing that behavior (https://github.com/psf/requests/issues/5714)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.