diff --git a/devserver/index.js b/devserver/index.js new file mode 100644 index 00000000..6f60d572 --- /dev/null +++ b/devserver/index.js @@ -0,0 +1,17 @@ +/** + * Dev server for local development + * - serve static files from frontend + * - proxy /api calls to 8081 + * - proxy /tiles calls to 8082 + */ +const path = require('path') + +const express = require('express') +const proxy = require('express-http-proxy'); + +const app = express() +app.use(express.static(path.join(__dirname, '..', 'frontend'))) +app.use('/api', proxy('localhost:8081')) +app.use('/tiles', proxy('localhost:8082')) + +app.listen(8080, () => console.log('Dev server listening on port 8080...')) diff --git a/devserver/package.json b/devserver/package.json new file mode 100644 index 00000000..61f38419 --- /dev/null +++ b/devserver/package.json @@ -0,0 +1,17 @@ +{ + "name": "cl-devserver", + "version": "1.0.0", + "description": "Development server to proxy", + "private": true, + "scripts": { + "start": "node index.js", + "debug": "DEBUG=express:* node index.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Tom Russell", + "license": "GPL-3.0", + "dependencies": { + "express": "^4.16.3", + "express-http-proxy": "^1.2.0" + } +}