mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-02 21:43:39 +01:00
Remove pages/api/proxy.js as it was an open proxy
- The only location pages/api/proxy was used was for icon loading in item.jsx, simply returning the icon URL instead worked just fine. There was no need to proxy icon requests. fixes: #327
This commit is contained in:
parent
4503612bf0
commit
c3a623c329
@ -10,7 +10,7 @@ import { SettingsContext } from "utils/contexts/settings";
|
||||
|
||||
function resolveIcon(icon) {
|
||||
if (icon.startsWith("http")) {
|
||||
return `/api/proxy?url=${encodeURIComponent(icon)}`;
|
||||
return icon;
|
||||
}
|
||||
|
||||
if (icon.startsWith("/")) {
|
||||
|
@ -1,59 +0,0 @@
|
||||
import https from "https";
|
||||
|
||||
import getRawBody from "raw-body";
|
||||
|
||||
import { httpRequest, httpsRequest } from "utils/proxy/http";
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const headers = ["X-API-Key", "Authorization"].reduce((obj, key) => {
|
||||
if (req.headers && Object.prototype.hasOwnProperty.call(req.headers, key.toLowerCase())) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
obj[key] = req.headers[key.toLowerCase()];
|
||||
}
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
const url = new URL(req.query.url);
|
||||
|
||||
if (url.protocol === "https:") {
|
||||
// this agent allows us to bypass the certificate check
|
||||
// which is required for most self-signed certificates
|
||||
const httpsAgent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
||||
const [status, contentType, data] = await httpsRequest(url, {
|
||||
agent: httpsAgent,
|
||||
method: req.method,
|
||||
headers,
|
||||
body:
|
||||
req.method === "GET" || req.method === "HEAD"
|
||||
? null
|
||||
: await getRawBody(req, {
|
||||
encoding: "utf8",
|
||||
}),
|
||||
});
|
||||
|
||||
res.setHeader("Content-Type", contentType);
|
||||
return res.status(status).send(data);
|
||||
}
|
||||
const [status, contentType, data] = await httpRequest(url, {
|
||||
method: req.method,
|
||||
headers,
|
||||
body:
|
||||
req.method === "GET" || req.method === "HEAD"
|
||||
? null
|
||||
: await getRawBody(req, {
|
||||
encoding: "utf8",
|
||||
}),
|
||||
});
|
||||
|
||||
res.setHeader("Content-Type", contentType);
|
||||
return res.status(status).send(data);
|
||||
}
|
@ -13,7 +13,7 @@ export default function Component({ service }) {
|
||||
const { data: moviesData, error: moviesError } = useWidgetAPI(widget, "movies");
|
||||
|
||||
if (episodesError || moviesError) {
|
||||
return <Container error="widget.api_error" />;
|
||||
return <Container error={t("widget.api_error")} />;
|
||||
}
|
||||
|
||||
if (!episodesData || !moviesData) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user