Fix: Use HTTP instead of HTTPS for local development BOTSERVER_URL
This commit is contained in:
parent
1f95ac7a15
commit
718afeb4b6
2 changed files with 31 additions and 27 deletions
|
|
@ -16,7 +16,11 @@ async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
let app = ui_server::configure_router();
|
let app = ui_server::configure_router();
|
||||||
|
|
||||||
let addr = std::net::SocketAddr::from(([0, 0, 0, 0], 3000));
|
let port: u16 = std::env::var("BOTUI_PORT")
|
||||||
|
.ok()
|
||||||
|
.and_then(|p| p.parse().ok())
|
||||||
|
.unwrap_or(3001);
|
||||||
|
let addr = std::net::SocketAddr::from(([0, 0, 0, 0], port));
|
||||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||||
info!("UI server listening on {}", addr);
|
info!("UI server listening on {}", addr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,14 @@
|
||||||
<title>General Bots</title>
|
<title>General Bots</title>
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||||
<script>
|
<script>
|
||||||
|
// BotServer URL - configurable via window.BOTSERVER_URL or defaults to same origin port 8088
|
||||||
|
const BOTSERVER_URL =
|
||||||
|
window.BOTSERVER_URL || "http://localhost:8088";
|
||||||
|
const BOTSERVER_WS_URL = BOTSERVER_URL.replace(
|
||||||
|
"https://",
|
||||||
|
"wss://",
|
||||||
|
).replace("http://", "ws://");
|
||||||
|
|
||||||
// Message Type Constants inline since we don't have a /shared route
|
// Message Type Constants inline since we don't have a /shared route
|
||||||
const MessageType = {
|
const MessageType = {
|
||||||
EXTERNAL: 0,
|
EXTERNAL: 0,
|
||||||
|
|
@ -891,10 +899,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebSocketUrl() {
|
function getWebSocketUrl() {
|
||||||
const p = "ws:",
|
const s = currentSessionId || crypto.randomUUID(),
|
||||||
s = currentSessionId || crypto.randomUUID(),
|
|
||||||
u = currentUserId || crypto.randomUUID();
|
u = currentUserId || crypto.randomUUID();
|
||||||
return `${p}//localhost:8080/ws?session_id=${s}&user_id=${u}`;
|
return `${BOTSERVER_WS_URL}/ws?session_id=${s}&user_id=${u}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initializeAuth() {
|
async function initializeAuth() {
|
||||||
|
|
@ -907,7 +914,7 @@
|
||||||
b = p.length > 0 ? p[0] : "default";
|
b = p.length > 0 ? p[0] : "default";
|
||||||
console.log("Bot name:", b);
|
console.log("Bot name:", b);
|
||||||
const r = await fetch(
|
const r = await fetch(
|
||||||
`/api/auth?bot_name=${encodeURIComponent(b)}`,
|
`${BOTSERVER_URL}/api/auth?bot_name=${encodeURIComponent(b)}`,
|
||||||
),
|
),
|
||||||
a = await r.json();
|
a = await r.json();
|
||||||
console.log("Auth response:", a);
|
console.log("Auth response:", a);
|
||||||
|
|
@ -933,7 +940,7 @@
|
||||||
|
|
||||||
async function loadSessions() {
|
async function loadSessions() {
|
||||||
try {
|
try {
|
||||||
const r = await fetch("http://localhost:8080/api/sessions"),
|
const r = await fetch(`${BOTSERVER_URL}/api/sessions`),
|
||||||
s = await r.json(),
|
s = await r.json(),
|
||||||
h = document.getElementById("history");
|
h = document.getElementById("history");
|
||||||
h.innerHTML = "";
|
h.innerHTML = "";
|
||||||
|
|
@ -953,10 +960,9 @@
|
||||||
|
|
||||||
async function createNewSession() {
|
async function createNewSession() {
|
||||||
try {
|
try {
|
||||||
const r = await fetch(
|
const r = await fetch(`${BOTSERVER_URL}/api/sessions`, {
|
||||||
"http://localhost:8080/api/sessions",
|
method: "POST",
|
||||||
{ method: "POST" },
|
}),
|
||||||
),
|
|
||||||
s = await r.json();
|
s = await r.json();
|
||||||
currentSessionId = s.session_id;
|
currentSessionId = s.session_id;
|
||||||
hasReceivedInitialMessage = false;
|
hasReceivedInitialMessage = false;
|
||||||
|
|
@ -990,9 +996,7 @@
|
||||||
|
|
||||||
async function loadSessionHistory(s) {
|
async function loadSessionHistory(s) {
|
||||||
try {
|
try {
|
||||||
const r = await fetch(
|
const r = await fetch(`${BOTSERVER_URL}/api/sessions/${s}`),
|
||||||
"http://localhost:8080/api/sessions/" + s,
|
|
||||||
),
|
|
||||||
h = await r.json(),
|
h = await r.json(),
|
||||||
m = document.getElementById("messages");
|
m = document.getElementById("messages");
|
||||||
m.innerHTML = "";
|
m.innerHTML = "";
|
||||||
|
|
@ -1523,17 +1527,14 @@
|
||||||
async function startVoiceSession() {
|
async function startVoiceSession() {
|
||||||
if (!currentSessionId) return;
|
if (!currentSessionId) return;
|
||||||
try {
|
try {
|
||||||
const r = await fetch(
|
const r = await fetch(`${BOTSERVER_URL}/api/voice/start`, {
|
||||||
"http://localhost:8080/api/voice/start",
|
method: "POST",
|
||||||
{
|
headers: { "Content-Type": "application/json" },
|
||||||
method: "POST",
|
body: JSON.stringify({
|
||||||
headers: { "Content-Type": "application/json" },
|
session_id: currentSessionId,
|
||||||
body: JSON.stringify({
|
user_id: currentUserId,
|
||||||
session_id: currentSessionId,
|
}),
|
||||||
user_id: currentUserId,
|
}),
|
||||||
}),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
d = await r.json();
|
d = await r.json();
|
||||||
if (d.token) {
|
if (d.token) {
|
||||||
await connectToVoiceRoom(d.token);
|
await connectToVoiceRoom(d.token);
|
||||||
|
|
@ -1548,7 +1549,7 @@
|
||||||
async function stopVoiceSession() {
|
async function stopVoiceSession() {
|
||||||
if (!currentSessionId) return;
|
if (!currentSessionId) return;
|
||||||
try {
|
try {
|
||||||
await fetch("http://localhost:8080/api/voice/stop", {
|
await fetch(`${BOTSERVER_URL}/api/voice/stop`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ session_id: currentSessionId }),
|
body: JSON.stringify({ session_id: currentSessionId }),
|
||||||
|
|
@ -1568,8 +1569,7 @@
|
||||||
async function connectToVoiceRoom(t) {
|
async function connectToVoiceRoom(t) {
|
||||||
try {
|
try {
|
||||||
const r = new LiveKitClient.Room(),
|
const r = new LiveKitClient.Room(),
|
||||||
p = "ws:",
|
u = `${BOTSERVER_WS_URL}/voice`;
|
||||||
u = `${p}//localhost:8080/voice`;
|
|
||||||
await r.connect(u, t);
|
await r.connect(u, t);
|
||||||
|
|
||||||
voiceRoom = r;
|
voiceRoom = r;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue