diff --git a/package.json b/package.json new file mode 100644 index 0000000..29cb56d --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "minetest-tile-server", + "version": "1.0.0", + "description": "Minetest tileserver =======", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/thomasrudin-mt/minetest-tile-server.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/thomasrudin-mt/minetest-tile-server/issues" + }, + "homepage": "https://github.com/thomasrudin-mt/minetest-tile-server#readme", + "dependencies": { + "connect": "^3.6.6", + "http-proxy": "^1.17.0", + "serve-static": "^1.13.2" + } +} diff --git a/proxy.js b/proxy.js new file mode 100644 index 0000000..1dca50f --- /dev/null +++ b/proxy.js @@ -0,0 +1,30 @@ + +var httpProxy = require('http-proxy'), + http = require("http"), + serveStatic = require('serve-static'), + connect = require('connect'); + + +var proxy = httpProxy.createProxy({ + target: "https://pandorabox.io/map", + secure: false +}); + +var app = connect() +.use("/", function(req, res, next){ + if (req.url.substring(0,3) == "/js"){ + console.log("Local: " + req.url); + next(); + return; + } + + console.log("Remote: " + req.url); + proxy.web(req, res); +}) +.use(serveStatic("src/main/resources/public")); + +var server = http.createServer(app); + +server.listen(8080); + +console.log("Listening on http://127.0.0.1:8080");