Frontend config support for AU. New absolute server url settings.

refs #104
This commit is contained in:
softsimon
2020-11-23 02:30:46 +07:00
parent bd1440ce96
commit d2cd595da6
16 changed files with 68 additions and 66 deletions

View File

@@ -1,4 +1,5 @@
import 'zone.js/dist/zone-node';
import './generated-config';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
@@ -16,6 +17,9 @@ const template = fs.readFileSync(path.join(__dirname, '../../mempool/browser/',
const win = domino.createWindow(template);
// @ts-ignore
win.__env = global.__env;
// @ts-ignore
win.matchMedia = () => {
return {
@@ -41,7 +45,6 @@ global['localStorage'] = {
key: () => '',
};
// The Express app is exported so that it can be used by serverless Functions.
export function app(): express.Express {
const server = express();
@@ -70,7 +73,8 @@ export function app(): express.Express {
));
server.get('/api/**', createProxyMiddleware({
target: 'http://localhost:50001',
// @ts-ignore
target: win.__env.ELECTRS_ABSOLUTE_URL_SERVER,
changeOrigin: true,
pathRewrite: {'^/api' : '/'}
},
@@ -90,7 +94,7 @@ function run(): void {
// Start up the Node server
const server = app();
server.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
console.log(`Node Express server listening on port ${port}`);
});
}