Added a fallback for x-forwarded-for header

This commit is contained in:
Giuseppe Digilio
2018-07-05 09:25:35 +02:00
parent 3126a96554
commit 6b7c748251

View File

@@ -28,7 +28,7 @@ export class ServerAuthService extends AuthService {
headers = headers.append('Accept', 'application/json'); headers = headers.append('Accept', 'application/json');
headers = headers.append('Authorization', `Bearer ${token.accessToken}`); headers = headers.append('Authorization', `Bearer ${token.accessToken}`);
// NB this is used to pass server client IP check. // NB this is used to pass server client IP check.
const clientIp = this.req.get('x-forwarded-for'); const clientIp = this.req.get('x-forwarded-for') || this.req.connection.remoteAddress;
headers = headers.append('X-Forwarded-For', clientIp); headers = headers.append('X-Forwarded-For', clientIp);
options.headers = headers; options.headers = headers;