Hello, how would I be able to allow fly-client-ip passthrough on my express-js app?
I’ve tried proxy_proto but this causes my application to refuse connections (I’ve included the error below)
[error] could not proxy TCP data to/from instance: failed to copy (direction=client->server, error=Transport endpoint is not connected (os error 107))
Im using express but I am open to using other libraries, I would heavily prefer to stick to Javascript and it is important for me to be able to handle TLS on my own
[[services]]
internal_port = 3000
protocol = "tcp"
processes = ['app']
force_https = true
[[services.ports]]
port = 443
[[vm]]
size = 'shared-cpu-1x'
Here is the JS code (doesn’t include routes obviously)
const express = require('express');
const app = express();
const https = require('https');
app.set('trust proxy', true);
app.engine('html', require('ejs').renderFile);
app.set('trust proxy', true);
//setting privatekey and certificate isn't included
const credentials = {
key: privateKey,
cert: certificate
};
const httpsServer = https.createServer(credentials, app);
const PORT = process.env.PORT || 3000;
httpsServer.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}`);
});