initial commit for welsh government planning appeals application
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# Server Configuration
|
||||
|
||||
If your project requires a more complex setup in terms of server configuration please add your files to this directory.
|
||||
@@ -0,0 +1,37 @@
|
||||
// Node only has partial ES6 support, import/export is not
|
||||
// yet officially supported so we have to use require instead.
|
||||
const express = require('express');
|
||||
const next = require('next');
|
||||
const compression = require('compression');
|
||||
// const cookieParser = require('cookie-parser');
|
||||
const port = parseInt(process.env.PORT, 10) || 3000;
|
||||
const app = next({ dev: process.env.NODE_ENV !== 'production' });
|
||||
const handle = app.getRequestHandler();
|
||||
|
||||
|
||||
// Having trouble with X-origin client side, setup a proxy here
|
||||
// const proxy = require('http-proxy-middleware');
|
||||
// const EXTERNAL_API = 'http://example.com/api';
|
||||
|
||||
app.prepare().then(() => {
|
||||
const server = express();
|
||||
|
||||
// const api_proxy = proxy(EXTERNAL_API, { changeOrigin: true });
|
||||
// Enable compression locally, helps page load times because... why not.
|
||||
server.use(compression());
|
||||
|
||||
// Parse cookies on the server, which we will pass through to React
|
||||
// server.use(cookieParser());
|
||||
|
||||
// Enable your new proxy below
|
||||
// server.use(api_proxy);
|
||||
|
||||
server.get('*', (req, res) => {
|
||||
return handle(req, res);
|
||||
});
|
||||
|
||||
server.listen(port, (err) => {
|
||||
if (err) throw err;
|
||||
console.log(`💻 Ready on http://localhost:${port}`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
const path = require('path');
|
||||
|
||||
const setup = ({ server }) => {
|
||||
server.get('/robots.txt', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../static', 'robots.txt'));
|
||||
});
|
||||
|
||||
server.get('/humans.txt', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../static', 'humans.txt'));
|
||||
});
|
||||
|
||||
server.get('/sitemap.xml', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../static', 'sitemap.xml'));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module.exports = setup;
|
||||
@@ -0,0 +1,9 @@
|
||||
const path = require('path')
|
||||
|
||||
const setup = ({ server }) => {
|
||||
server.get('/robots.txt', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../static', 'robots.txt'));
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = setup
|
||||
Reference in New Issue
Block a user