Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/app/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export function AppInterface(props: {
<GlobalSyncProvider>
<Dynamic
component={props.router ?? Router}
base={import.meta.env.BASE_URL.replace(/\/$/, "") || undefined}
root={(routerProps) => <RouterRoot appChildren={props.children}>{routerProps.children}</RouterRoot>}
>
<Route path="/" component={HomeRoute} />
Expand Down
7 changes: 5 additions & 2 deletions packages/app/src/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
1 change: 1 addition & 0 deletions packages/app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading