-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (38 loc) · 1.13 KB
/
server.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
37
38
39
40
41
42
43
44
45
46
47
48
require("newrelic");
const express = require('express');
const path = require('path');
const axios = require('axios');
const servicePath = "http://54.191.49.243:8081";
const app = express();
const port = process.env.PORT || 9009;
console.log(__dirname);
app.use(express.static(path.resolve(__dirname, 'public')));
app.use('/:houseId', express.static(path.resolve(__dirname, "public")));
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get("/houseId/listedAgent/:houseId", (req, res) => {
axios
.get(`${servicePath}/houseId/listedAgent/${req.params.houseId}`)
.then(data => {
res.send(data.data);
})
.catch(e => {
console.log(e);
});
});
app.get("/houseId/premierAgents/:houseId", (req, res) => {
axios
.get(`${servicePath}/houseId/listedAgent/${req.params.houseId}`)
.then(data => {
res.send(data.data);
})
.catch(e => {
console.log(e);
});
});
app.listen(port, () => {
console.log(`Proxy Server running at port ${port}`)
});