pull/18209/merge
Alexey Volkov 2026-04-08 06:01:27 +00:00 committed by GitHub
commit 5684c685a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 2 deletions

View File

@ -295,6 +295,7 @@ export function AppInterface(props: {
<Dynamic
component={props.router ?? Router}
root={(routerProps) => <RouterRoot appChildren={props.children}>{routerProps.children}</RouterRoot>}
base={import.meta.env.BASE_URL.replace(/\/$/, "") || undefined}
>
<Route path="/" component={HomeRoute} />
<Route path="/:dir" component={DirectoryLayout}>

View File

@ -98,10 +98,13 @@ if (!(root instanceof HTMLElement) && import.meta.env.DEV) {
}
const getCurrentUrl = () => {
let serverBaseUrl = import.meta.env.VITE_OPENCODE_SERVER_BASE_URL ?? ""
// Normalizing slashes. Add starting slash if needed, remove trailing slash. Default value will be empty string.
serverBaseUrl = ("/" + serverBaseUrl.replace(/^\//, "")).replace(/\/$/, "")
if (location.hostname.includes("opencode.ai")) return "http://localhost:4096"
if (import.meta.env.DEV)
return `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}`
return location.origin
return `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}{serverBaseUrl}`
return location.origin + serverBaseUrl
}
const getDefaultUrl = () => {

View File

@ -1,6 +1,7 @@
import "solid-js"
interface ImportMetaEnv {
readonly BASE_URL: string
readonly VITE_OPENCODE_SERVER_HOST: string
readonly VITE_OPENCODE_SERVER_PORT: string
}

View File

@ -2,6 +2,7 @@ import { defineConfig } from "vite"
import desktopPlugin from "./vite"
export default defineConfig({
base: process.env.VITE_BASE_URL || "/",
plugins: [desktopPlugin] as any,
server: {
host: "0.0.0.0",