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

How to get client ip address in Fresh framework #103

Open
Triment opened this issue Mar 29, 2024 · 0 comments
Open

How to get client ip address in Fresh framework #103

Triment opened this issue Mar 29, 2024 · 0 comments
Labels
release 发布文章

Comments

@Triment
Copy link
Owner

Triment commented Mar 29, 2024

Fresh is a next generation web framework, I'll take a glimpse of works that get ip address for you in this post.

Get client ip from Fresh so easy, Beside ip headers, We can access to client info by context.remoteAddr.

export const handler: Handlers = {
  async GET(_req, ctx) {
    console.log(ctx.remoteAddr.hostname,ctx.remoteAddr.port);//print client ip and port
  ...
  }
}
@Triment Triment added the release 发布文章 label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release 发布文章
Projects
None yet
Development

No branches or pull requests

1 participant