Skip to content

Bypass www redirect for API and login requests (incl. safety-data), replaces #32 - #33

Merged
atalyaalon merged 3 commits into
mainfrom
claude/laughing-galileo-165xk1-www-api-redirect
Nov 30, 2026
Merged

atalyaalon merged 3 commits into
mainfrom
claude/laughing-galileo-165xk1-www-api-redirect

Conversation

@atalyaalon

@atalyaalon atalyaalon commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

♻️ Replaces #32

🔴 Broken right now, fixed by this PR

  • What's broken: since Nov 30, 00:23 UTC, when merging Only deploy the anyway apps from main (stop deploys from any branch push) #27 and Reduce DB backup costs: monthly dumps + expire dumps older than 1 year #24 redeployed main without Tamar's change, www.anyway.co.il redirects API requests to anyway.co.il again. Browsers block redirected cross-site API calls (CORS), so these apps can't load their data:
    • media.anyway.co.il (infographics): shows "Invalid Component widget."
    • reports.anyway.co.il (anyway-reports): calls www.anyway.co.il/api/schools-names, /api/embedded-reports and /api/injured-around-schools…
    • safety-data, if its API URL is www.anyway.co.il
  • History: the redirect exists since Nov 6. Tamar's fix was live from Nov 28 18:49 to Nov 30 00:23 UTC.

What it does

File: apps-dfc2/anyway/compose.yaml

A Traefik router, anyway-www-api, with priority 100. That's higher than the www → anyway.co.il redirect router, whose default priority is its rule length, 24. For these paths on www.anyway.co.il, requests go straight to anyway-nginx:

Paths Used by
/api/… infographics (media.anyway.co.il), anyway-reports, the mobile app, Telegram notifications
/authorize/…, /callback/…, /user/…, /logout anyway login, including the infographics login popup
/sd-authorize/…, /sd-callback/…, /sd-user/… safety-data login (AuthService.ts, with credentials)
/involved, /involved/…, /city safety-data data (AccidentService.ts, CityService.ts; JSON content type, so preflighted)

Every other path on www.anyway.co.il still redirects to anyway.co.il, as before.

Why:

  • Browsers block a redirected cross-site API call: the 301 has no CORS headers. Login and cookie requests break too.
  • Native apps and server code follow redirects, so they were never affected.
  • Skipping the redirect changes nothing else: it's the same backend (anyway-nginx), the same hostname, and the same certificate.

How the list was found: I searched every data-for-change repo for code that calls www.anyway.co.il. Browser apps that call it outside these paths: none.

  • Still redirected, fine: page links and the old iOS app's /markers, which are page visits or native requests.
  • A known frontend bug, not this PR's: 2 infographics admin URLs are built with a double slash (//user/...). Those still redirect.

Commits

  1. bd37921 (Tamar): /api/, /authorize/, /callback/, /user/, /logout
  2. d96c7d7: safety-data login routes (/sd-*), plus a comment explaining the rule
  3. 5d0cb34: safety-data data routes (/involved, /city)

Merging

  • It merges cleanly. The change against main is 10 lines in one file, and the backup schedule stays monthly (10 0 1 * *).
  • docker compose config passes.
  • Merging redeploys dfc2 only (dfc2 anyway CI). Only anyway-nginx is recreated, a few seconds' blip, below the uptime monitor's ~2.5 minute alert threshold. dfc is not touched.
  • No Terraform involved.

After merging, check

  1. The dfc2 deploy log still shows 10 0 1 * *.
  2. The API answers cross-site without a redirect. Expect 200 plus an Access-Control-Allow-Origin header:
    curl -s -o /dev/null -D- -H 'Origin: https://media.anyway.co.il' 'https://www.anyway.co.il/api/news-flash?pageSize=1' | head -12
  3. Pages still redirect. Expect 301 to anyway.co.il:
    curl -sI https://www.anyway.co.il/ | head -3
  4. Open media.anyway.co.il (widgets load), reports.anyway.co.il, and safety-data.anyway.co.il, and log in once through anyway and once through safety-data.

Review

A Fable 5.2 review found no blockers: safe to merge. It confirmed the media.anyway.co.il cause from the code. Its open question, safety-data's /involved and /city, is now covered.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV

tkalir and others added 2 commits November 30, 2026 01:48
…rule

safety-data-client logs in with credentials via ${apiUrl}/sd-authorize/,
/sd-callback/ and /sd-user/ (anyway flask_app.py), which the bypass did
not cover. Adding them is harmless: same backend, only the redirect is
skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
@atalyaalon
atalyaalon requested review from tkalir and ziv17 November 30, 2026 01:49
safety-data-client calls ${API_ANYWAY_URL}/involved, /involved/groupby and
/city with a JSON content type (preflighted CORS), which a redirect breaks
if that URL is www.anyway.co.il. Harmless otherwise: same backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants