Cache:
Change URL method to work with older nodejs versions git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@58699 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
36ff7b58a8
commit
cfed36d65b
|
@ -5,6 +5,7 @@ let app = express();
|
||||||
let mcache = require('memory-cache');
|
let mcache = require('memory-cache');
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
const prom = require('prom-client');
|
const prom = require('prom-client');
|
||||||
|
const URL = require('url');
|
||||||
|
|
||||||
let cors = require('cors');
|
let cors = require('cors');
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
@ -38,7 +39,7 @@ let cache = (duration) => {
|
||||||
if(req.query.url) {
|
if(req.query.url) {
|
||||||
let key = '__express__' + req.query.url;
|
let key = '__express__' + req.query.url;
|
||||||
let cachedBody = mcache.get(key);
|
let cachedBody = mcache.get(key);
|
||||||
const url = new URL(req.query.url);
|
const url = new URL.parse(req.query.url);
|
||||||
const target = url.host + '/' + url.pathname.split('/')[1];
|
const target = url.host + '/' + url.pathname.split('/')[1];
|
||||||
const scheme = url.protocol.replace(':', '');
|
const scheme = url.protocol.replace(':', '');
|
||||||
if (cachedBody) {
|
if (cachedBody) {
|
||||||
|
|
Loading…
Reference in New Issue