mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-01-30 15:19:32 +08:00
Feat: add forward addr
This commit is contained in:
parent
239d0cd0b7
commit
75ee272d3a
@ -207,4 +207,26 @@ router.get("/quick_install_list", permission({ level: 10 }), async (ctx) => {
|
||||
}
|
||||
});
|
||||
|
||||
// [Top-level Permission]
|
||||
// forward request
|
||||
router.all(
|
||||
"/forward",
|
||||
permission({ level: 10 }),
|
||||
validator({ query: { target: String } }),
|
||||
async (ctx) => {
|
||||
const ADDR = String(ctx.query.target);
|
||||
try {
|
||||
const response = await axios.request({
|
||||
method: ctx.request.method,
|
||||
url: ADDR,
|
||||
data: ctx.request.body
|
||||
});
|
||||
if (response.status !== 200) throw new Error("Response code != 200");
|
||||
ctx.body = response.data;
|
||||
} catch (err) {
|
||||
ctx.body = [];
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
Loading…
Reference in New Issue
Block a user