mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
fix(subsonic): sync Rust HTTP UA with main webview UA (#235)
Use the main window WebView user agent as the runtime source for Rust-side HTTP clients and refresh the audio engine client when the UA changes. This keeps backend and WebView requests aligned while preserving a simple startup sync flow.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { StrictMode } from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import App from './App';
|
||||
import './i18n';
|
||||
@@ -15,6 +16,19 @@ try {
|
||||
(window as any).__PSY_WINDOW_LABEL__ = 'main';
|
||||
}
|
||||
|
||||
// Sync backend HTTP User-Agent from the main webview once at startup.
|
||||
try {
|
||||
const windowLabel = (window as any).__PSY_WINDOW_LABEL__ ?? 'main';
|
||||
if (windowLabel === 'main') {
|
||||
const ua = window.navigator.userAgent?.trim();
|
||||
if (ua) {
|
||||
void invoke('set_subsonic_wire_user_agent', { userAgent: ua, windowLabel });
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore in non-Tauri runtimes.
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
|
||||
Reference in New Issue
Block a user