Skip to content
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

[Bug]: If hostname is localhost, the server fallback URL always defaults to localhost:3000, even when it is running on a different port #4362

Open
amanape opened this issue Oct 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@amanape
Copy link
Collaborator

amanape commented Oct 14, 2024

          If hostname is `localhost`, the server fallback URL to communicate with the backend is always `localhost:3000`. This is incorrect in your scenario since the server is now running on `localhost:3001`.

export const getValidFallbackHost = () => {
if (typeof window !== "undefined") {
const { hostname, host } = window.location;
if (hostname !== "localhost") return host;
}
// Fallback is localhost:3000 because that is the default port for the server
return "localhost:3000";
};

For now, you can run OpenHands locally (pull and run make build && make run). Feel free to set the environment variable to whichever URL you need here:

VITE_BACKEND_BASE_URL="localhost:3000" # Backend URL without protocol (e.g. localhost:3000)

Note that in this mode, the frontend is expected to be served on localhost:3001, another limitation but its because:

allow_origins=['http://localhost:3001', 'http://127.0.0.1:3001'],

Originally posted by @amanape in #4344 (comment)

@amanape amanape changed the title [Bug]: If hostname is localhost, the server fallback URL always defaults to localhost:3000, even when running on a different port [Bug]: If hostname is localhost, the server fallback URL always defaults to localhost:3000, even when it is running on a different port Oct 14, 2024
@amanape amanape added the bug Something isn't working label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant