[PR #126] [MERGED] fix(api): Better support to reverse proxy deploy #1118

Closed
opened 2026-05-03 01:59:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/reconurge/flowsint/pull/126
Author: @gustavorps
Created: 2/20/2026
Status: Merged
Merged: 3/4/2026
Merged by: @dextmorgn

Base: mainHead: fix/proxy-api


📝 Commits (4)

  • d526697 feat(api): added fastapi standard
  • da02805 fix(api): added ignore_trailing_slash=True to face 307 redirect reverse proxy issue
  • 5ee7bf2 fix(api): added redirect_slashes=False to face 307 redirect reverse proxy issue
  • b2cfc67 fix(app): removing slashes

📊 Changes

7 files changed (+892 additions, -11 deletions)

View changed files

📝 flowsint-api/app/api/routes/chat.py (+1 -1)
📝 flowsint-api/app/api/routes/enrichers.py (+1 -1)
📝 flowsint-api/app/api/routes/flows.py (+1 -1)
📝 flowsint-api/app/api/routes/types.py (+1 -1)
📝 flowsint-api/app/main.py (+1 -1)
📝 flowsint-api/poetry.lock (+886 -5)
📝 flowsint-api/pyproject.toml (+1 -1)

📄 Description

This PR aligns FastAPI routing behavior with proxy-safe deployment practices (NGINX/Traefik/Caddy), focusing on eliminating slash-based redirects and making endpoint matching explicit.

Why this change

Behind reverse proxies, automatic trailing-slash redirects can cause:

  • HTTPS → HTTP downgrade in redirect URLs
  • redirect loops
  • inconsistent behavior between local and production environments

To reduce these risks, route handling is now explicit and redirect-free.

What changed

1) Route normalization across API routers

Updated root route decorators from @router.get("/") to @router.get("") in:

  • chat.py
  • enrichers.py
  • flows.py
  • types.py

This standardizes route definitions and avoids accidental dual-path behavior.

[1]](diffhunk://#diff-e3588298dd3b26a8d46216216a41d77d2584ee58896b8ffffeb99ed74df78d66L26-R26) [2] [3] [4]

2) FastAPI app slash behavior

Updated app configuration in main.py to:

  • redirect_slashes=False
  • ignore_trailing_slash=True

This prevents automatic 307/308 slash redirects and allows consistent handling of URLs with/without trailing slash.

3) Dependency update

Updated pyproject.toml to use fastapi[standard], ensuring recommended runtime dependencies are installed.


Expected impact

  • More predictable routing behind reverse proxies
  • Fewer proxy-related redirect issues
  • Cleaner API behavior with fewer unnecessary redirects

Important deployment note

For full proxy correctness, runtime/proxy configuration is still required (outside this code change), including:

  • running with proxy headers enabled (e.g., fastapi run ... --proxy-headers)
  • forwarding X-Forwarded-Proto, X-Forwarded-For, and Host at the proxy layer

These are critical to ensure correct scheme detection, docs URL generation, and client IP handling.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/reconurge/flowsint/pull/126 **Author:** [@gustavorps](https://github.com/gustavorps) **Created:** 2/20/2026 **Status:** ✅ Merged **Merged:** 3/4/2026 **Merged by:** [@dextmorgn](https://github.com/dextmorgn) **Base:** `main` ← **Head:** `fix/proxy-api` --- ### 📝 Commits (4) - [`d526697`](https://github.com/reconurge/flowsint/commit/d52669740b5ed06330312a04fd03a24701e377d9) feat(api): added fastapi standard - [`da02805`](https://github.com/reconurge/flowsint/commit/da0280506e9358de2a5bd268d8ab742dbff00b34) fix(api): added ignore_trailing_slash=True to face 307 redirect reverse proxy issue - [`5ee7bf2`](https://github.com/reconurge/flowsint/commit/5ee7bf24e05c698827dfa1dd74e91992e5805920) fix(api): added redirect_slashes=False to face 307 redirect reverse proxy issue - [`b2cfc67`](https://github.com/reconurge/flowsint/commit/b2cfc67117cd67815fa7ee4740f402d0dba5e5b7) fix(app): removing slashes ### 📊 Changes **7 files changed** (+892 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `flowsint-api/app/api/routes/chat.py` (+1 -1) 📝 `flowsint-api/app/api/routes/enrichers.py` (+1 -1) 📝 `flowsint-api/app/api/routes/flows.py` (+1 -1) 📝 `flowsint-api/app/api/routes/types.py` (+1 -1) 📝 `flowsint-api/app/main.py` (+1 -1) 📝 `flowsint-api/poetry.lock` (+886 -5) 📝 `flowsint-api/pyproject.toml` (+1 -1) </details> ### 📄 Description This PR aligns FastAPI routing behavior with proxy-safe deployment practices (NGINX/Traefik/Caddy), focusing on eliminating slash-based redirects and making endpoint matching explicit. ### Why this change Behind reverse proxies, automatic trailing-slash redirects can cause: - HTTPS → HTTP downgrade in redirect URLs - redirect loops - inconsistent behavior between local and production environments To reduce these risks, route handling is now explicit and redirect-free. ### What changed #### 1) Route normalization across API routers Updated root route decorators from `@router.get("/")` to `@router.get("")` in: - `chat.py` - `enrichers.py` - `flows.py` - `types.py` This standardizes route definitions and avoids accidental dual-path behavior. [1]](diffhunk://#diff-e3588298dd3b26a8d46216216a41d77d2584ee58896b8ffffeb99ed74df78d66L26-R26) [[2]](diffhunk://#diff-6cd67793f3473f2d21888c8a1cde82a1f918adb8fd367221fc273b27a7efffe1L30-R30) [[3]](diffhunk://#diff-4660bebc8d52e3ad322d18c4e6bdf9b501a007473bb91f728ab46fb997e54a5eL72-R72) [[4]](diffhunk://#diff-87e71a44c625840689b51e67d5143f249809fb800d21452e4f915d9c9d92ea2bL12-R12) #### 2) FastAPI app slash behavior Updated app configuration in `main.py` to: - `redirect_slashes=False` - `ignore_trailing_slash=True` This prevents automatic 307/308 slash redirects and allows consistent handling of URLs with/without trailing slash. #### 3) Dependency update Updated pyproject.toml to use `fastapi[standard]`, ensuring recommended runtime dependencies are installed. --- ### Expected impact - More predictable routing behind reverse proxies - Fewer proxy-related redirect issues - Cleaner API behavior with fewer unnecessary redirects ### Important deployment note For full proxy correctness, runtime/proxy configuration is still required (outside this code change), including: - running with proxy headers enabled (e.g., `fastapi run ... --proxy-headers`) - forwarding `X-Forwarded-Proto`, `X-Forwarded-For`, and `Host` at the proxy layer These are critical to ensure correct scheme detection, docs URL generation, and client IP handling. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-03 01:59:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/flowsint#1118