Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request IP Address #46

Open
SellersEvan opened this issue Mar 28, 2024 · 0 comments
Open

Request IP Address #46

SellersEvan opened this issue Mar 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@SellersEvan
Copy link
Member

Is your feature request related to a problem? Please describe.
Add the ability to get the IP address from the request.

Describe the solution you'd like

const http = require('http');

const server = http.createServer((req, res) => {
  // Get connection details
  const { remoteAddress, remotePort, localAddress, localPort } = req.connection;

  console.log('Remote Address:', remoteAddress);
  console.log('Remote Port:', remotePort);
  console.log('Local Address:', localAddress);
  console.log('Local Port:', localPort);

  // Send a response
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World!\n');
});

const PORT = 3000;
server.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});

Describe alternatives you've considered
N/A

Additional context
Add support to Metadapter-Events and SherpaJS Event module to support this (and Carrot's backend).

@SellersEvan SellersEvan added the enhancement New feature or request label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant