git@154.201.72.75:Tianpao/MTB_Backend.git
This commit is contained in:
32
resmc.js
Normal file
32
resmc.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const express = require('express');
|
||||
const axios = require('axios');
|
||||
|
||||
const app = express();
|
||||
const port = 3002;
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const userAgent = req.headers['user-agent'];
|
||||
if (userAgent && (userAgent.includes('PCL') || userAgent.includes('FCL') || userAgent.includes('HMCL') || userAgent.includes('BakaXL'))) {
|
||||
next(); // User-Agent 已经包含所需字符串,无需修改
|
||||
} else {
|
||||
// 重定向前设置 User-Agent
|
||||
req.customUserAgent = 'MTB Hello';
|
||||
next();
|
||||
}
|
||||
});
|
||||
//////
|
||||
app.get('/:path(*)', (req, res) => {
|
||||
const path = req.params.path;
|
||||
const userAgent = req.customUserAgent || 'MTB Hello';
|
||||
const redirectUrl = `https://bmclapi2.bangbang93.com/assets/${path}`;
|
||||
res.set({
|
||||
'Location': redirectUrl,
|
||||
'User-Agent': userAgent
|
||||
}).status(302).end();
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.listen(3002, () => {
|
||||
console.log('Server is running on port 3002');
|
||||
});
|
||||
Reference in New Issue
Block a user