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

deno serve doesn't support the second connInfo parameter #24099

Closed
bendechrai opened this issue Jun 4, 2024 · 1 comment · Fixed by #25606
Closed

deno serve doesn't support the second connInfo parameter #24099

bendechrai opened this issue Jun 4, 2024 · 1 comment · Fixed by #25606
Assignees
Labels
feat new feature (which has been agreed to/accepted) serve
Milestone

Comments

@bendechrai
Copy link

Version: Deno 1.44.0

I'm trying to get the IP address of the client when running declarative scripts through deno serve.

It seems the fetch method only accepts the first request parameter, and if I expect and address the connInfo parameter, I get an Internal Server Error and a console output of TypeError: Cannot read properties of undefined (reading 'remoteAddr').

Are declarative scripts intended to not have access to this additional information? Or have I overlooked something?

export default {
  async fetch(request, connInfo) {
    const clientIP = connInfo.remoteAddr.hostname;
    return new Response(`Hello world! Your IP address is ${clientIP}`);
  },
};

Cheers,
Ben

(As reported on discord and added here on request)

@bartlomieju bartlomieju added suggestion suggestions for new features (yet to be agreed) needs discussion this topic needs further discussion to determine what action to take serve labels Jun 4, 2024
@ArmaanAS
Copy link
Contributor

I was trying to switch over from Deno.serve() to deno serve --parallel but the lack of IP Address support is a blocker.

@bartlomieju bartlomieju added feat new feature (which has been agreed to/accepted) and removed needs discussion this topic needs further discussion to determine what action to take 2.0 triage required suggestion suggestions for new features (yet to be agreed) labels Sep 2, 2024
@bartlomieju bartlomieju modified the milestones: 2.0.0, 2.1.0 Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted) serve
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants