Proxy Plex through stemserve (/plex/) so HTTPS pages avoid mixed-content blocks
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b53a720c4
commit
7ca9d0374d
2 files changed
+33
-3
No files matched your search
+3
-3
@@ -60,7 +60,7 @@ const plexHeaders = token => ({
|
||||
|
||||
async function px(path, params = {}) {
|
||||
if (!S.plex) throw new Error("Not signed in to Plex");
|
||||
const u = new URL(S.plex.url + path);
|
||||
const u = new URL(S.plex.url + path, location.href);
|
||||
for (const [k, v] of Object.entries(params)) u.searchParams.set(k, v);
|
||||
const r = await fetch(u, { headers: plexHeaders(S.plex.token) });
|
||||
if (!r.ok) throw new Error(`Plex ${r.status}`);
|
||||
@@ -782,7 +782,7 @@ const routes = {
|
||||
if (S.plex) secs = ((await px("/library/sections").catch(() => ({}))).Directory || []).filter(d => d.type === "artist");
|
||||
view.innerHTML = `<h1>Settings</h1>
|
||||
<h2>Plex</h2><div class="form">
|
||||
<p class="note">${S.plex ? `Plex: <b>${esc(S.plex.name && S.plex.name !== S.plex.url ? S.plex.name + " (" + S.plex.url + ")" : S.plex.url)}</b>${S.plex.env ? " (set by the server)" : ""}` : "Not signed in."}</p>
|
||||
<p class="note">${S.plex ? `Plex: <b>${esc(S.plex.env ? "via this server" : S.plex.name && S.plex.name !== S.plex.url ? S.plex.name + " (" + S.plex.url + ")" : S.plex.url)}</b>${S.plex.env ? " (set by the server)" : ""}` : "Not signed in."}</p>
|
||||
<div class="row"><button class="btn primary" id="signin">Sign in with Plex</button>${S.plex ? `<button class="btn" id="signout">Sign out</button>` : ""}<span class="note" id="sstatus"></span></div>
|
||||
${secs.length > 1 ? `<label>Music library<select id="sec">${secs.map(d => `<option value="${d.key}" ${d.key == S.section ? "selected" : ""}>${esc(d.title)}</option>`).join("")}</select></label>` : ""}
|
||||
<details><summary class="note">Enter a server and token by hand</summary><div class="form" style="margin-top:12px">
|
||||
@@ -850,7 +850,7 @@ async function autoConnect() {
|
||||
if (!S.plex || S.plex.env) {
|
||||
try {
|
||||
const c = await fetch(stemBase() + "/api/config" + stemQuery()).then(r => r.ok ? r.json() : null);
|
||||
if (c?.plex) S.plex = { ...c.plex, name: "", env: true };
|
||||
if (c?.plex) S.plex = { token: c.plex.token, url: stemBase() + "/plex", name: "", env: true };
|
||||
else if (S.plex?.env) S.plex = null;
|
||||
save();
|
||||
} catch {}
|
||||
|
||||
Reference in new issue
Block a user