-
Notifications
You must be signed in to change notification settings - Fork 8k
fix: replace history-based navigation (-1 as To) with dynamic URL using globalThis.location.origin in SettingsPage #10256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ng window.location.origin in SettingsPage
- Replace backTo={-1 as To} with window.location.origin
- Previously, if the user opened the Settings page directly and clicked Back, they would be redirected to the browser's default page (e.g., home page or previous site).
- Now, they will always be redirected to the Langflow home page.
- This ensures that the Back button works correctly across different environments (development, staging, production).
- Maintains the same functionality while making navigation environment-independent.
WalkthroughUpdates Settings page back navigation: adds a flowsUrl derived from window.location.origin and passes it to PageLayout’s backTo prop, changing the back action to navigate to the Flows page. No other logic or exports modified. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant SP as SettingsPage
participant PL as PageLayout
participant B as Browser
U->>SP: Open Settings
SP->>PL: Render with backTo = flowsUrl (origin + "/flows")
U->>PL: Click Back
PL->>B: Navigate to flowsUrl (/flows on current origin)
Note over PL,B: Back target changed from -1 (no-op) to explicit /flows
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/frontend/src/pages/SettingsPage/index.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/frontend/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
src/frontend/src/**/*.{ts,tsx,js,jsx}: All frontend TypeScript and JavaScript code should be located under src/frontend/src/ and organized into components, pages, icons, stores, types, utils, hooks, services, and assets directories as per the specified directory layout.
Use React 18 with TypeScript for all UI components in the frontend.
Format all TypeScript and JavaScript code using the make format_frontend command.
Lint all TypeScript and JavaScript code using the make lint command.
Files:
src/frontend/src/pages/SettingsPage/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Test Starter Templates
| const flowsUrl = `${window.location.origin}/flows`; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential base path issue: use a relative path instead.
Constructing the URL with window.location.origin will fail if the application is deployed under a base path (e.g., example.com/langflow/), as it would navigate to example.com/flows instead of example.com/langflow/flows. Additionally, using a full URL may trigger a full page reload rather than client-side routing.
Apply this diff to use a relative path:
- const flowsUrl = `${window.location.origin}/flows`;
+ const flowsUrl = "/flows";Or pass the path directly to the backTo prop:
- const flowsUrl = `${window.location.origin}/flows`;
-
// Hides the General settings if there is nothing to show
const showGeneralSettings = ENABLE_PROFILE_ICONS || hasStore || !autoLogin;
const sidebarNavItems: {And update line 94:
<PageLayout
- backTo={flowsUrl}
+ backTo="/flows"
title="Settings"
description="Manage the general settings for Langflow."
>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const flowsUrl = `${window.location.origin}/flows`; | |
| @@ src/frontend/src/pages/SettingsPage/index.tsx:18 | |
| const flowsUrl = "/flows"; | |
| @@ src/frontend/src/pages/SettingsPage/index.tsx:94 | |
| backTo="/flows" |
🤖 Prompt for AI Agents
In src/frontend/src/pages/SettingsPage/index.tsx around lines 18-19, the code
builds flowsUrl using window.location.origin which breaks when the app is served
under a base path and forces a full-page reload; replace the absolute URL with a
relative path (e.g., '/flows' or just 'flows' as appropriate) and pass that
relative path directly to the backTo prop so client-side routing is used instead
of constructing a full origin-based URL.
|



This PR replaces history-based navigation
-1 as Towith a dynamic URL usingglobalThis.location.origin.This ensures consistent navigation behavior when users access the Settings page directly and click the Back button.
The change happens inside the PageLayout component, specifically in the
backToproperty.Motivation
How to Test
✅ You should be redirected to the Langflow home page instead of the browser’s default previous page.
Summary by CodeRabbit