Skip to content

Commit f8ae62a

Browse files
man4ishclaude
andcommitted
fix: use relative URLs for /_svc/ routes on web
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 54feeb8 commit f8ae62a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/ui/pages/Workbench.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useEffect, useMemo } from "react";
2+
import { isElectron } from "../lib/session";
23

34
function getInitialHost() {
45
return (
@@ -31,7 +32,7 @@ function buildCategories(BASE) {
3132
{ label:"Launcher", url:"http://localhost:5190", icon:"🔬", desc:"Jupyter · RStudio · VS Code" },
3233
{ label:"Workflows", url:"/_svc/workflows", icon:"⚡", desc:"WDL/NF/Snake/CWL" },
3334
{ label:"Dev Hub", url:"/_svc/devhub", icon:"🛠️", desc:"Knowledge graph · RAG search" },
34-
{ label:"Metrics", url:"http://localhost/_svc/monitor", icon:"📊", desc:"Grafana dashboard" },
35+
{ label:"Metrics", url:"/_svc/monitor", icon:"📊", desc:"Grafana dashboard" },
3536
{ label:"Grafana", url:"http://localhost:3000", icon:"📈", desc:"Metrics dashboards" },
3637
]
3738
},
@@ -133,9 +134,15 @@ export default function Workbench() {
133134
return () => clearInterval(id);
134135
}, [BASE]);
135136

137+
// Electron's <webview> needs a fully-qualified src (it isn't part of the
138+
// host page's browsing context, so relative URLs won't resolve). In a
139+
// browser tab — web/beta mode — relative /_svc/* URLs must stay relative:
140+
// nginx-router already proxies them on the same origin, and prefixing
141+
// them with http://localhost causes mixed-content blocks on HTTPS and
142+
// resolves to the visitor's own machine instead of the server.
136143
const open = (url, label) => {
137144
let absolute;
138-
if (url.startsWith('/')) {
145+
if (url.startsWith('/') && isElectron()) {
139146
const devHost = url.startsWith('/_svc/') && import.meta.env.DEV
140147
? 'http://localhost:5174'
141148
: 'http://localhost';

0 commit comments

Comments
 (0)