mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
[ALL-551] chore(frontend): Retrieve APP_MODE from the server (#4423)
This commit is contained in:
@@ -8,7 +8,7 @@ RUN npm install -g npm@10.5.1
|
||||
RUN npm ci
|
||||
|
||||
COPY ./frontend ./
|
||||
RUN npm run make-i18n && npm run build
|
||||
RUN npm run build
|
||||
|
||||
FROM python:3.12.3-slim AS backend-builder
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@ VITE_MOCK_API="false" # true or false
|
||||
|
||||
# GitHub OAuth
|
||||
VITE_GITHUB_CLIENT_ID=""
|
||||
VITE_APP_MODE="oss" # "oss" or "saas"
|
||||
|
||||
3
frontend/global.d.ts
vendored
Normal file
3
frontend/global.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
interface Window {
|
||||
__APP_MODE__?: "saas" | "oss";
|
||||
}
|
||||
3
frontend/public/config.json
Normal file
3
frontend/public/config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"APP_MODE": "oss"
|
||||
}
|
||||
@@ -60,6 +60,15 @@ class OpenHands {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
static async getConfig(): Promise<{ APP_MODE: "saas" | "oss" }> {
|
||||
const response = await fetch(`${OpenHands.BASE_URL}/config.json`, {
|
||||
headers: {
|
||||
"Cache-Control": "no-cache",
|
||||
},
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of files available in the workspace
|
||||
* @param token User token provided by the server
|
||||
|
||||
@@ -113,7 +113,7 @@ function Home() {
|
||||
const { files } = useSelector((state: RootState) => state.initalQuery);
|
||||
|
||||
const handleConnectToGitHub = () => {
|
||||
const isSaas = import.meta.env.VITE_APP_MODE === "saas";
|
||||
const isSaas = window.__APP_MODE__ === "saas";
|
||||
|
||||
if (isSaas) {
|
||||
window.location.href = githubAuthUrl;
|
||||
|
||||
@@ -26,6 +26,9 @@ import NewProjectIcon from "#/assets/new-project.svg?react";
|
||||
import DocsIcon from "#/assets/docs.svg?react";
|
||||
|
||||
export const clientLoader = async () => {
|
||||
const config = await OpenHands.getConfig();
|
||||
window.__APP_MODE__ = config.APP_MODE;
|
||||
|
||||
let token = localStorage.getItem("token");
|
||||
const ghToken = localStorage.getItem("ghToken");
|
||||
|
||||
|
||||
@@ -798,4 +798,4 @@ def github_callback(auth_code: AuthCode):
|
||||
)
|
||||
|
||||
|
||||
app.mount('/', StaticFiles(directory='./frontend/build', html=True), name='dist')
|
||||
app.mount('/', StaticFiles(directory='./frontend/build/client', html=True), name='dist')
|
||||
|
||||
Reference in New Issue
Block a user