fix: Make feature server URL configurable#6020
fix: Make feature server URL configurable#6020kchawlani19 wants to merge 1 commit intofeast-dev:masterfrom
Conversation
3082026 to
b641677
Compare
b641677 to
c3ea607
Compare
There was a problem hiding this comment.
need to change placeholder as well
| feastObjectQuery, | ||
| }: RegularFeatureViewCustomTabProps) => { | ||
| const data = feastObjectQuery.data as any; | ||
| const defaultServerUrl = |
There was a problem hiding this comment.
I think it could be a module-level constant, declaring it inside the component means it gets re-evaluated on every render
|
Can we also add the documentation ? |
Signed-off-by: kchawlani19 <kchawlan@redhat.com> Made-with: Cursor
c3ea607 to
0000261
Compare
There was a problem hiding this comment.
🟡 useEffect unconditionally persists default URL to localStorage, preventing env var updates from taking effect for returning users
The useEffect on line 35-37 saves serverUrl to localStorage on every change, including the initial render. When a user first visits the page, the defaultServerUrl (from the env var) is immediately persisted to localStorage. If an admin later changes REACT_APP_FEAST_FEATURE_SERVER_URL and rebuilds the app, returning users will still see the old URL because localStorage (containing the old default) takes precedence over the new env var value in the useState initializer at line 26-28. This undermines the stated purpose of this PR — making the default URL configurable — since the configuration change only affects brand-new users who have never visited the page.
A fix would be to only write to localStorage when the user explicitly edits the URL (e.g., in the onChange handler), or to store a flag distinguishing user-edited values from auto-persisted defaults.
(Refers to lines 35-37)
Prompt for agents
In ui/src/pages/feature-views/CurlGeneratorTab.tsx, the useEffect at lines 35-37 unconditionally persists serverUrl to localStorage on every change including the initial default value. This means if the admin changes REACT_APP_FEAST_FEATURE_SERVER_URL and rebuilds, returning users will still see the old default.
To fix this, persist the URL to localStorage only when the user explicitly edits it. One approach:
1. Remove the useEffect that auto-saves serverUrl to localStorage (lines 35-37).
2. In the onChange handler for the EuiFieldText (around line 112), save to localStorage there:
onChange={(e) => {
setServerUrl(e.target.value);
localStorage.setItem("feast-feature-server-url", e.target.value);
}}
This way, localStorage only contains a value if the user explicitly typed one, and the env var default will always be respected for users who haven't customized the URL.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
@kchawlani19 this needs to be handled, move localStorage.setItem into the onChange handler and drop the useEffect
Summary
Test plan