// Adapt URL-passed auth into basic HTTP auth for QGIS compatibility. const express = require('express'); const request = require('request'); const app = express(); const port = 8356; const reqOpts = { method: 'GET', headers: { Authorization: '' }, url: 'http://localhost:8355', timeout: 1200000 // 20 minutes } app.all(/.*/, (req, res) => { // Verify Inputs if (!req.query.auth) { res.status(401).send('Unauthorized'); return; } let hazePwHash = null; let hazeUser = null; if (req.query.auth) { request({ ...reqOpts, url: reqOpts.url + req.baseUrl, headers: { Authorization: `Basic ${req.query.auth}` } }, (error, response, body) => { if (error) { res.status(500).send('Internal Server Error'); return; } else if (response.statusCode !== 200) { res.status(response.statusCode).send(body); return; } else { res.setHeader('Content-Type', 'application/json'); res.send(body); } }) } }); app.listen(port, () => { console.log(`Server is running on http://localhost:${port}`); });