@uniorg/localneo
Version:
Run your SAP-WebIDE based applications locally using the neo-app.json as a web server config.
31 lines (26 loc) • 666 B
JavaScript
const Router = require('./Router')
const proxy = require('http-proxy')
class Destination extends Router {
constructor ({ url, auth, remotePath }) {
super()
this.url = url
this.remotePath = remotePath
this.proxy = proxy.createProxyServer({
target: (url || '') + '/' + (remotePath || ''),
auth: auth,
secure: false,
prependPath: true,
changeOrigin: true
})
this.proxy.on('error', (err) => console.error(err.message))
}
handle (request, response) {
try {
this.proxy.web(request, response)
} catch (e) {
console.error(e)
response.end(501)
}
}
}
module.exports = Destination