feat!: Include PUBLIC_URL in defaultProjectListPromise URL in /ui#5125
Merged
redhatHameed merged 1 commit intofeast-dev:masterfrom Mar 7, 2025
Conversation
We currently always fetch the project list from the root path by
default, even if the UI is served from a non-root path via PUBLIC_URL.
It seems reasonable to assume that the project list would be served
from the same path as the UI by default, so change the default project
list URL to include the basename from PUBLIC_URL. This way you don't
need to specify a custom `projectListPromise` for this base case, as
shown by the changes in ui/src/index.tsx.
BREAKING CHANGE:
The PUBLIC_URL environment variable is now taken into account by default
when fetching the projects list. This is a breaking change only if all
these points apply:
1. You're using Feast UI as a module
2. You're serving the UI files from a non-root path via the PUBLIC_URL
environment variable
3. You're serving the project list from the root path
4. You're not passing the `feastUIConfigs.projectListPromise` prop to
the FeastUI component
In this case, you need to explicitly fetch the project list from the
root path via the `feastUIConfigs.projectListPromise` prop:
```diff
const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
- <FeastUI />
+ <FeastUI
+ feastUIConfigs={{
+ projectListPromise: fetch("/projects-list.json", {
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then((res) => res.json())
+ }}
+ />
</React.StrictMode>
);
```
Signed-off-by: Harri Lehtola <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
We currently always fetch the project list from the root path by default, even if the UI is served from a non-root path via PUBLIC_URL.
It seems reasonable to assume that the project list would be served from the same path as the UI by default, so change the default project list URL to include the basename from PUBLIC_URL. This way you don't need to specify a custom
projectListPromisefor this base case, as shown by the changes in ui/src/index.tsx.Breaking change
The PUBLIC_URL environment variable is now taken into account by default when fetching the project list. This is a breaking change only if all these points apply:
feastUIConfigs.projectListPromiseprop to the FeastUI componentIn this case, you need to explicitly fetch the project list from the root path via the
feastUIConfigs.projectListPromiseprop:const root = createRoot(document.getElementById("root")!); root.render( <React.StrictMode> - <FeastUI /> + <FeastUI + feastUIConfigs={{ + projectListPromise: fetch("/projects-list.json", { + headers: { + "Content-Type": "application/json", + }, + }).then((res) => res.json()) + }} + /> </React.StrictMode> );Which issue(s) this PR fixes:
No existing issue, this came up in #5004 (comment):
Misc
I made this pull request because this new behavior would better match my expectations as a developer than the previous one, and would require less code if e.g. the PUBLIC_URL changes in different environments for a project. But I may well have missed something because I don't know the situations in which people use PUBLIC_URL. So feel free to dismiss this if it's not worth the hassle. 🙂