Commit d3327e9e authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '188-proxy-sitemap-xml' into 'master'

Resolve "Proxy sitemap.xml"

Closes #188

See merge request genesys-pgr/genesys-ui!203
parents 12b2acfa b40cd6f2
......@@ -10,6 +10,7 @@ import {readFileSync} from 'fs';
import config from './config';
import prerenderer from './middleware/prerenderer';
import robots from './robots';
import sitemap from './sitemap';
import i18nServer from '../i18n/i18n-server';
import httpProxy from './middleware/httpProxy';
const i18nextMiddleware = require('i18next-express-middleware'); // has no proper import yet
......@@ -44,6 +45,8 @@ app.get('/en/*', (req, res) => {
const redirectPath = oldPath.substr(3, oldPath.length);
res.redirect(301, `${config.frontendPath}${redirectPath}`);
});
// Handle sitemap.xml and references files
app.get('/sitemap*.xml', sitemap);
// Enable compression
app.use(compression());
// robots.txt
......
import axios from 'axios';
import config from './config';
const sitemap = (req, res) => {
axios({
method: 'get',
url: `${config.apiUrl}${req.path}`,
}).then(response => {
return res.set('Content-Type', 'text/xml').send(response.data);
}).catch(error => {
res.status(error.status).end(error.data);
});
};
export default sitemap;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment