1
Fork 0

test ignore

This commit is contained in:
Ashley 2023-11-22 16:11:01 +00:00
parent 88c745e892
commit 9a66aa08a7

View file

@ -1,6 +1,7 @@
const express = require("express"); const express = require("express");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const { URL } = require("url"); const { URL } = require("url");
const { Readable } = require("node:stream");
// Array of hostnames that will be proxied // Array of hostnames that will be proxied
const URL_WHITELIST = [ const URL_WHITELIST = [
@ -58,6 +59,8 @@ app.use(function (req, res, next) {
* @param {express.Response} res * @param {express.Response} res
*/ */
const proxy = async (req, res) => { const proxy = async (req, res) => {
const { fetch } = await import("undici")
try { try {
let url; let url;
@ -80,7 +83,7 @@ const proxy = async (req, res) => {
method: req.method, method: req.method,
}); });
f.body.pipe(res); Readable.fromWeb(f.body).pipe(res);
} catch (e) { } catch (e) {
console.log(`==> Error: ${e}`); console.log(`==> Error: ${e}`);
res.status(500).send("Internal server error"); res.status(500).send("Internal server error");