-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
59 lines (49 loc) · 1.65 KB
/
Copy pathserver.js
File metadata and controls
59 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* DP Shop (Proxy)
*
* Proxies incoming Wii ECS requests to the WiiMart server.
* The ECS server's structure is controlled by the WiiMart team.
* Content of the DLCs are controlled by DanceParty team.
*
* Made by yunyl
*/
require("dotenv").config();
const express = require('express');
const axios = require('axios');
const app = express();
const signale = require('signale');
const logger = signale;
const config = require('./config');
app.use(express.json());
app.use(express.text({ type: 'text/*' }));
app.use(express.raw({ type: 'application/*', limit: '10mb' }));
app.post('/ecs/services/ECommerceSOAP', async (req, res) => {
try {
logger.debug('Received POST request to /ecs/services/ECommerceSOAP');
// Forward request to target server with same headers and body
const response = await axios({
method: 'POST',
url: `${config.WIIMART_FQDN}/oss/ecs/services/ECommerceSOAP`,
headers: req.headers,
data: req.body,
validateStatus: () => true, // Accept any status code
maxRedirects: 0
});
// Forward response headers back to client
Object.keys(response.headers).forEach(key => {
res.setHeader(key, response.headers[key]);
});
// Send response with same status code and body
res.status(response.status).send(response.data);
logger.info(`Forwarded response with status: ${response.status}`);
} catch (error) {
logger.error('Proxy error:', error.message);
res.status(500).json({
error: 'Proxy error',
message: error.message
});
}
});
app.listen(config.PORT, () => {
logger.success(`DP Shop Proxy running on port ${config.PORT}`);
});