Skip to content

🐛 BUG: impossible to get remote client IP address from incoming Astro.request #3708

@JReinhold

Description

@JReinhold

What version of astro are you using?

1.0.0-beta.56

Are you using an SSR adapter? If so, which one?

Deno

What package manager are you using?

pnpm

What operating system are you using?

Mac

Describe the Bug

The Request object that can be read via Astro.request during SSR only contains a subset of the http.IncomingMessage. This means that properties like socket are not available and thus it's impossible to get the remote IP address of the client.

Reading the request IP is common for geo-related topics like geofencing content, adhering to local laws (eg. EU cookie consent), etc., and I can't currently come up with a valid workaround for this.

It looks like the createRequest function is responsible for this:

export function createRequest({

This is both an issue when using the vite dev server as well as running a production server with the Deno adapter (and most likely all the other SSR adapters as well, but I might be wrong here).

I'm unsure if there are other valuable properties that are being stripped from the IncomingMessage, all I've noticed is the socket property.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ufjx2c?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions