Skip to content

Commit 52a8e71

Browse files
committed
Add Referer header to fix 403 on image CDN
img.kidplan.com rejects requests without a Referer pointing back to app.kidplan.com. Browsers send this automatically; our session didn't.
1 parent 6295be9 commit 52a8e71

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

kidplan_fetcher/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def main():
135135
output_dir = Path(args.output)
136136
session = requests.Session()
137137
session.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0"
138+
session.headers["Referer"] = BASE_URL + "/"
138139

139140
if args.cookie:
140141
session.cookies.set(".ASPXAUTH", args.cookie, domain="app.kidplan.com")

tests/test_integration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
@pytest.fixture(scope="module")
3434
def session():
3535
s = requests.Session()
36-
s.headers["User-Agent"] = "Mozilla/5.0 (kidplan-fetcher-test)"
36+
s.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0"
37+
s.headers["Referer"] = "https://app.kidplan.com/"
3738
assert login(s, USERNAME, PASSWORD), "Login failed — check credentials"
3839
return s
3940

0 commit comments

Comments
 (0)