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

Client IP is always 'null' #599

Open
Joschi84 opened this issue Apr 8, 2024 · 2 comments
Open

Client IP is always 'null' #599

Joschi84 opened this issue Apr 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Joschi84
Copy link

Joschi84 commented Apr 8, 2024

What version of Elysia.JS is running?

Elysia: command not found

What platform is your computer?

Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

Hello Community,

I'm trying to get the client IP Address, but i only always get 'null'. What I am doing wrong?
Hopefully someone can help.
Elysia is working well (even if 'Elysia --revision' gives Elysia: command not found).
Bun is on the newest Version (1.1.3). And Elysia should be also very up-to-date.
Here is the code:

import { Elysia } from "elysia";

const app = new Elysia()
  .use(app => app.derive(({ request }) => ({ ip: app.server?.requestIP(request) })))
  .post("/test", async ({ body, ip }) => {
      console.log(body, ip) 
  })
  .listen(2000)

What is the expected behavior?

Getting client ip address.

What do you see instead?

null

Additional information

No response

@Joschi84 Joschi84 added the bug Something isn't working label Apr 8, 2024
@kidqueb
Copy link
Contributor

kidqueb commented Apr 8, 2024

Your snippet works for me when logging ip, but it is currently logging id.

@Joschi84
Copy link
Author

Joschi84 commented Apr 8, 2024

My fault. I edited it. But this was just a typing error here in the browser. For me, the problem remains unclear. Any further ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants