Skip to content

Conversation

@MODSetter
Copy link
Owner

@MODSetter MODSetter commented Oct 31, 2025

Description

Motivation and Context

Deployment ease

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR adds ProxyHeadersMiddleware to FastAPI to properly handle proxy headers (e.g., from Cloudflare) ensuring HTTPS is used in redirects, and systematically removes trailing slashes from all API endpoint paths across backend routes, frontend hooks, and browser extension code to prevent unnecessary redirects. Additionally, connector creation forms are updated to include new periodic indexing fields (periodic_indexing_enabled, indexing_frequency_minutes, next_scheduled_at) set to null by default.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/app/app.py
2 surfsense_backend/app/routes/chats_routes.py
3 surfsense_backend/app/routes/documents_routes.py
4 surfsense_backend/app/routes/llm_config_routes.py
5 surfsense_backend/app/routes/logs_routes.py
6 surfsense_backend/app/routes/podcasts_routes.py
7 surfsense_backend/app/routes/search_source_connectors_routes.py
8 surfsense_backend/app/routes/search_spaces_routes.py
9 surfsense_backend/app/routes/airtable_add_connector_route.py
10 surfsense_backend/app/routes/google_calendar_add_connector_route.py
11 surfsense_backend/app/routes/google_gmail_add_connector_route.py
12 surfsense_web/hooks/use-chat.ts
13 surfsense_web/hooks/use-connectors.ts
14 surfsense_web/hooks/use-documents.ts
15 surfsense_web/hooks/use-llm-configs.ts
16 surfsense_web/hooks/use-logs.ts
17 surfsense_web/hooks/use-search-source-connectors.ts
18 surfsense_web/hooks/use-document-types.ts
19 surfsense_web/hooks/use-connector-edit-page.ts
20 surfsense_web/components/sidebar/AppSidebarProvider.tsx
21 surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx
22 surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx
23 surfsense_web/app/dashboard/[search_space_id]/documents/webpage/page.tsx
24 surfsense_web/app/dashboard/[search_space_id]/documents/youtube/page.tsx
25 surfsense_web/app/dashboard/[search_space_id]/connectors/add/github-connector/page.tsx
26 surfsense_web/app/dashboard/[search_space_id]/connectors/add/elasticsearch-connector/page.tsx
27 surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx
28 surfsense_web/app/dashboard/[search_space_id]/connectors/add/clickup-connector/page.tsx
29 surfsense_web/app/dashboard/[search_space_id]/connectors/add/confluence-connector/page.tsx
30 surfsense_web/app/dashboard/[search_space_id]/connectors/add/discord-connector/page.tsx
31 surfsense_web/app/dashboard/[search_space_id]/connectors/add/jira-connector/page.tsx
32 surfsense_web/app/dashboard/[search_space_id]/connectors/add/linear-connector/page.tsx
33 surfsense_web/app/dashboard/[search_space_id]/connectors/add/linkup-api/page.tsx
34 surfsense_web/app/dashboard/[search_space_id]/connectors/add/luma-connector/page.tsx
35 surfsense_web/app/dashboard/[search_space_id]/connectors/add/notion-connector/page.tsx
36 surfsense_web/app/dashboard/[search_space_id]/connectors/add/searxng/page.tsx
37 surfsense_web/app/dashboard/[search_space_id]/connectors/add/serper-api/page.tsx
38 surfsense_web/app/dashboard/[search_space_id]/connectors/add/slack-connector/page.tsx
39 surfsense_web/app/dashboard/[search_space_id]/connectors/add/tavily-api/page.tsx
40 surfsense_browser_extension/background/messages/savedata.ts
41 surfsense_browser_extension/background/messages/savesnapshot.ts
42 surfsense_browser_extension/routes/pages/HomePage.tsx
⚠️ Inconsistent Changes Detected
File Path Warning
surfsense_backend/app/routes/documents_routes.py Two endpoints (get_document_type_counts and get_document_by_chunk_id) are moved from the end of the file to the middle without functional changes, which appears to be an unrelated reorganization
surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx Adds new fields periodic_indexing_enabled, indexing_frequency_minutes, and next_scheduled_at to connector creation, which seems like a new feature addition rather than just path refactoring

Need help? Join our Discord

Analyze latest changes

Summary by CodeRabbit

  • Chores

    • Standardized API endpoint URLs across the application by removing trailing slashes for consistent routing.
    • Added proxy header middleware support to properly handle HTTPS when running behind reverse proxies (e.g., Cloudflare).
  • New Features

    • Added periodic indexing configuration fields to all data connectors, enabling control over indexing frequency and scheduling.
    • Improved API request handling with enhanced header support.

…oxies

- Integrated ProxyHeadersMiddleware to ensure FastAPI correctly handles HTTPS in redirects when deployed behind a proxy, such as Cloudflare.
- This addition enhances security and proper URL handling in the application.
- Modified various FastAPI route definitions to remove trailing slashes for consistency across the application.
- Updated corresponding fetch calls in the frontend to align with the new endpoint structure.
- Ensured that all affected routes maintain their functionality without trailing slashes.
@vercel
Copy link

vercel bot commented Oct 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
surf-sense-frontend Ready Ready Preview Comment Oct 31, 2025 8:38am

@coderabbitai
Copy link

coderabbitai bot commented Oct 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR normalizes API endpoint paths by removing trailing slashes across backend FastAPI routes, frontend components, and browser extension code. Additionally, it adds ProxyHeadersMiddleware to handle proxy headers securely and includes three scheduling-related fields (periodic_indexing_enabled, indexing_frequency_minutes, next_scheduled_at) in connector creation payloads.

Changes

Cohort / File(s) Summary
Backend Middleware
surfsense_backend/app/app.py
Added ProxyHeadersMiddleware from uvicorn to trust proxy headers (e.g., from Cloudflare), positioned before CORS middleware for HTTPS redirect assurance behind a proxy.
Backend Routes - Trailing Slash Removal
surfsense_backend/app/routes/airtable_add_connector_route.py, google_calendar_add_connector_route.py, google_gmail_add_connector_route.py, chats_routes.py, documents_routes.py, llm_config_routes.py, logs_routes.py, podcasts_routes.py, search_source_connectors_routes.py, search_spaces_routes.py
Removed trailing slashes from all route decorator paths (e.g., /endpoint//endpoint), affecting multiple GET and POST endpoints without changing function signatures or control flow.
Frontend Connector Creation Payloads
surfsense_web/app/dashboard/[search_space_id]/connectors/add/{baidu-search-api,clickup-connector,confluence-connector,discord-connector,elasticsearch-connector,github-connector,jira-connector,linear-connector,linkup-api,luma-connector,notion-connector,searxng,serper-api,slack-connector,tavily-api}/page.tsx
Added three scheduling fields to connector creation payloads: periodic_indexing_enabled: false, indexing_frequency_minutes: null, next_scheduled_at: null. Also applied defensive null-coalescing for form watchers in Elasticsearch connector.
Frontend API Hooks - Trailing Slash Removal
surfsense_web/hooks/{use-chat.ts,use-connectors.ts,use-connector-edit-page.ts,use-document-types.ts,use-documents.ts,use-llm-configs.ts,use-logs.ts,use-search-source-connectors.ts}
Removed trailing slashes from API endpoint URLs in fetch calls. Added Content-Type: application/json header to LLM config POST request.
Frontend Pages & Components - Trailing Slash Removal
surfsense_web/app/dashboard/[search_space_id]/{chats/chats-client.tsx,documents/{webpage,youtube}/page.tsx,podcasts/podcasts-client.tsx}, surfsense_web/components/sidebar/AppSidebarProvider.tsx
Removed trailing slashes from endpoint URLs in fetch calls for chats, documents, and podcasts.
Browser Extension - Trailing Slash Removal
surfsense_browser_extension/{background/messages/{savedata.ts,savesnapshot.ts},routes/pages/HomePage.tsx}
Removed trailing slashes from API endpoint paths in background messages and page routing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Rationale: Despite affecting ~35+ files across frontend, backend, and browser extension, the changes follow a highly repetitive pattern (trailing slash removal and consistent field additions). All modifications are straightforward string/payload updates with no logic alterations.
  • Areas requiring extra attention:
    • Verify that all trailing slash removals in frontend hooks match corresponding backend route changes (consistency across stack)
    • Confirm the three scheduling fields (periodic_indexing_enabled, indexing_frequency_minutes, next_scheduled_at) are present in all connector creation pages
    • Validate that ProxyHeadersMiddleware placement in app.py is before CORS middleware as intended
    • Ensure query parameters (e.g., ?search_space_id=...) are correctly positioned after paths without trailing slashes

Possibly related PRs

Suggested reviewers

  • Utkarsh-Patel-13

Poem

🐰 A trailing slash journey ends today,
Normalized paths light up the way,
Scheduling fields hop into place,
Proxy headers embrace with grace,
The code now runs a cleaner race!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a0dc0e and ecd07d6.

📒 Files selected for processing (42)
  • surfsense_backend/app/app.py (2 hunks)
  • surfsense_backend/app/routes/airtable_add_connector_route.py (2 hunks)
  • surfsense_backend/app/routes/chats_routes.py (2 hunks)
  • surfsense_backend/app/routes/documents_routes.py (4 hunks)
  • surfsense_backend/app/routes/google_calendar_add_connector_route.py (2 hunks)
  • surfsense_backend/app/routes/google_gmail_add_connector_route.py (2 hunks)
  • surfsense_backend/app/routes/llm_config_routes.py (2 hunks)
  • surfsense_backend/app/routes/logs_routes.py (2 hunks)
  • surfsense_backend/app/routes/podcasts_routes.py (3 hunks)
  • surfsense_backend/app/routes/search_source_connectors_routes.py (3 hunks)
  • surfsense_backend/app/routes/search_spaces_routes.py (2 hunks)
  • surfsense_browser_extension/background/messages/savedata.ts (1 hunks)
  • surfsense_browser_extension/background/messages/savesnapshot.ts (1 hunks)
  • surfsense_browser_extension/routes/pages/HomePage.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx (2 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/clickup-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/confluence-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/discord-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/elasticsearch-connector/page.tsx (3 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/github-connector/page.tsx (2 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/jira-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/linear-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/linkup-api/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/luma-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/notion-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/searxng/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/serper-api/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/slack-connector/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/connectors/add/tavily-api/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/documents/webpage/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/documents/youtube/page.tsx (1 hunks)
  • surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx (1 hunks)
  • surfsense_web/components/sidebar/AppSidebarProvider.tsx (1 hunks)
  • surfsense_web/hooks/use-chat.ts (1 hunks)
  • surfsense_web/hooks/use-connector-edit-page.ts (1 hunks)
  • surfsense_web/hooks/use-connectors.ts (2 hunks)
  • surfsense_web/hooks/use-document-types.ts (1 hunks)
  • surfsense_web/hooks/use-documents.ts (2 hunks)
  • surfsense_web/hooks/use-llm-configs.ts (2 hunks)
  • surfsense_web/hooks/use-logs.ts (2 hunks)
  • surfsense_web/hooks/use-search-source-connectors.ts (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MODSetter MODSetter merged commit 9ce00ca into main Oct 31, 2025
6 of 7 checks passed
Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 7a0dc0e..ecd07d6

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (41)

surfsense_backend/app/routes/airtable_add_connector_route.py
surfsense_backend/app/routes/chats_routes.py
surfsense_backend/app/routes/documents_routes.py
surfsense_backend/app/routes/google_calendar_add_connector_route.py
surfsense_backend/app/routes/google_gmail_add_connector_route.py
surfsense_backend/app/routes/llm_config_routes.py
surfsense_backend/app/routes/logs_routes.py
surfsense_backend/app/routes/podcasts_routes.py
surfsense_backend/app/routes/search_source_connectors_routes.py
surfsense_backend/app/routes/search_spaces_routes.py
surfsense_browser_extension/background/messages/savedata.ts
surfsense_browser_extension/background/messages/savesnapshot.ts
surfsense_browser_extension/routes/pages/HomePage.tsx
surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/clickup-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/confluence-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/discord-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/elasticsearch-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/github-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/jira-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/linear-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/linkup-api/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/luma-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/notion-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/searxng/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/serper-api/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/slack-connector/page.tsx
surfsense_web/app/dashboard/[search_space_id]/connectors/add/tavily-api/page.tsx
surfsense_web/app/dashboard/[search_space_id]/documents/webpage/page.tsx
surfsense_web/app/dashboard/[search_space_id]/documents/youtube/page.tsx
surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx
surfsense_web/components/sidebar/AppSidebarProvider.tsx
surfsense_web/hooks/use-chat.ts
surfsense_web/hooks/use-connector-edit-page.ts
surfsense_web/hooks/use-connectors.ts
surfsense_web/hooks/use-document-types.ts
surfsense_web/hooks/use-documents.ts
surfsense_web/hooks/use-llm-configs.ts
surfsense_web/hooks/use-logs.ts
surfsense_web/hooks/use-search-source-connectors.ts

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.

2 participants