-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarousel-proxy.js
More file actions
67 lines (57 loc) · 2.07 KB
/
carousel-proxy.js
File metadata and controls
67 lines (57 loc) · 2.07 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
60
61
62
63
64
65
66
67
const express = require('express');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const url = require('url');
const path = require('path');
const cors = require('cors');
var proxy = require('http-proxy-middleware');
const axios = require('axios');
const { json, urlencoded } = bodyParser;
const app = express();
app.use(cors());
app.use(morgan('dev'));
app.use(json());
app.use(urlencoded({ extended: false }));
app.use('/rooms/:id/', express.static(path.resolve(__dirname, './public/')));
app.use('/rooms/:id/pictures', proxy({ target: 'http://localhost:4500/', changeOrigin: false }));
app.use('/rooms/:id/booking', proxy({ target: 'http://localhost:1337/', changeOrigin: false }));
app.use('/rooms/:id/listings', proxy({ target: 'http://localhost:3003/', changeOrigin: false }));
app.use('/rooms/:id/reviews', proxy({ target: 'http://localhost:3000/', changeOrigin: false }));
app.use('/rooms/:id/stars', proxy({ target: 'http://localhost:3000/', changeOrigin: false }));
app.use('/rooms/:id/query', proxy({ target: 'http://localhost:3000/', changeOrigin: false }));
app.use('/rooms/:id/hostDetails', proxy({ target: 'http://localhost:3000/', changeOrigin: false }));
app.get('/pictures', (req, res) => {
res.send(res.data);
});
app.get('/booking', (req, res) => {
res.send(res.data);
});
app.get('/reviews', (req, res) => {
res.send(res.data);
});
app.get('/stars', (req, res) => {
res.send(res.data);
});
app.get('/query', (req, res) => {
res.send(res.data);
});
app.get('/hostDetails', (req, res) => {
res.send(res.data);
});
// app.get('rooms/:id/booking', (req, res) => {
// axios.get('http://localhost:1337/rooms/:id/booking/')
// .then((data) => {
// console.log(data);
// res.header('Access-Control-Allow-Origin', '*');
// res.send(data);
// });
// });
// app.get('rooms/:id/booking', (req, res) => {
// axios.get('http://localhost:3003/rooms/:id/booking/')
// .then((data) => {
// console.log(data);
// res.header('Access-Control-Allow-Origin', '*');
// res.send(data);
// });
// });
app.listen(9999);