-
Notifications
You must be signed in to change notification settings - Fork 5
/
setupProxy.js
36 lines (32 loc) · 1.21 KB
/
setupProxy.js
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
// This file sets up React's proxy in development mode.
//
// Currently, non-native Node languages (e.g. typescript) are explicitly not supported:
// https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually
//
/* eslint-disable */
/* istanbul ignore file */
const resolve = require('resolve');
const express = require('express');
const { createProxyMiddleware: proxy } = require('http-proxy-middleware');
const { dirname, join } = require('path');
/**
* @param {import('connect').Server} app
*/
module.exports = function (app) {
app.use(proxy('/card', { target: 'http://localhost:3001/' }));
app.use(proxy('/convert', { target: 'http://localhost:3003/' }));
app.use(proxy('/admin', { target: 'http://localhost:3004/' }));
app.use('/machine-config', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.end(
JSON.stringify({
machineId: process.env.VX_MACHINE_ID || '0000',
codeVersion: process.env.VX_CODE_VERSION || 'dev',
})
);
});
const pdfjsDistBuildPath = dirname(
resolve.sync('pdfjs-dist', { basedir: join(__dirname, '..') })
);
app.use('/pdfjs-dist', express.static(pdfjsDistBuildPath));
};