mirror of
https://github.com/wukko/cobalt.git
synced 2025-04-30 06:24:25 +02:00
api/youtube-session: bypass proxy for requests
usually the session server is hosted locally, which means the proxy tries to access the wrong url
This commit is contained in:
parent
2d38d63003
commit
39274d88f6
@ -1,8 +1,11 @@
|
|||||||
import * as cluster from "../../misc/cluster.js";
|
import * as cluster from "../../misc/cluster.js";
|
||||||
|
|
||||||
|
import { Agent } from "undici";
|
||||||
import { env } from "../../config.js";
|
import { env } from "../../config.js";
|
||||||
import { Green, Yellow } from "../../misc/console-text.js";
|
import { Green, Yellow } from "../../misc/console-text.js";
|
||||||
|
|
||||||
|
const defaultAgent = new Agent();
|
||||||
|
|
||||||
let session;
|
let session;
|
||||||
|
|
||||||
const validateSession = (sessionResponse) => {
|
const validateSession = (sessionResponse) => {
|
||||||
@ -32,7 +35,11 @@ const loadSession = async () => {
|
|||||||
const sessionServerUrl = new URL(env.ytSessionServer);
|
const sessionServerUrl = new URL(env.ytSessionServer);
|
||||||
sessionServerUrl.pathname = "/token";
|
sessionServerUrl.pathname = "/token";
|
||||||
|
|
||||||
const newSession = await fetch(sessionServerUrl).then(a => a.json());
|
const newSession = await fetch(
|
||||||
|
sessionServerUrl,
|
||||||
|
{ dispatcher: defaultAgent }
|
||||||
|
).then(a => a.json());
|
||||||
|
|
||||||
validateSession(newSession);
|
validateSession(newSession);
|
||||||
|
|
||||||
if (!session || session.updated < newSession?.updated) {
|
if (!session || session.updated < newSession?.updated) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user