File size: 1,164 Bytes
6f7ef5c
 
 
 
66906f8
6f7ef5c
 
aa120c6
 
 
6f7ef5c
 
 
 
 
 
 
 
 
 
 
f85b485
 
069b249
f85b485
 
069b249
19d90a0
 
069b249
 
 
 
f85b485
 
 
069b249
6f7ef5c
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
const { createProxyMiddleware } = require('http-proxy-middleware');
const { env } = require('process');

const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` :
    env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'https://localhost:7217';

const context = [
    "/item",
    "/api/tierlist",
    "/api/item"
];

module.exports = function (app) {
    const appProxy = createProxyMiddleware(context, {
        target: target,
        secure: false,
        headers: {
            Connection: 'Keep-Alive'
        }
    });

    // Proxy uploads directly to MAMP
    const uploadsProxy = createProxyMiddleware('/api/item/uploads', {
        target: 'http://localhost:80', // MAMP Apache is on port 80
        changeOrigin: true,
        secure: false,
        pathRewrite: {
            // This is the fix: route the request to the new tierapp folder on MAMP
            '^/api/item/uploads': '/tierapp/item/uploads', 
        },
        onProxyReq: (proxyReq, req, res) => {
            console.log('Proxying uploads request to:', proxyReq.path);
        }
    });

    app.use(uploadsProxy);
    app.use(appProxy);
};