Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creating a simple ambassador container to override 404 HTTP responses.
let { Ambassador } = require('../node-ambassador/')
const TARGET = process.env['target_port'] || 8087
const PORT = process.env['port'] || 8080
const HTTP404 = `const HTTP404 =
HTTP/1.0 404 File not found
Server: Sitio 💥
Date: ${Date()}
Content-Type: text/html
Connection: close
<body>
<H1>Look Somewhere Else / Not Found</H1>
<img src="https://www.wykop.pl/cdn/c3201142/comment_E6icBQJrg2RCWMVsTm4mA3XdC9yQKIjM.gif">
</body>`
function override_404({service, server}) {
service.on('http:404', () => server.respond(HTTP404))
}
new Ambassador({port: PORT, target: TARGET})
.tunnel({override_404})
console.log(`listening for request in ${PORT} and targeting ${TARGET}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment