spin icon indicating copy to clipboard operation
spin copied to clipboard

Access client IP from SDK

Open ecumene opened this issue 2 years ago • 2 comments

We can already get the IP when using WAGI through the REMOTE_ADDR environment variable, but there's no way to access the client's IP when using the SDK.

Maybe we could use this standard way that proxies use to forward requests

ecumene avatar May 07 '22 14:05 ecumene

@radu-matei Could/should we add it to the request record in http-types.wit, or is that set in stone?

itowlson avatar May 11 '22 01:05 itowlson

Updating the request object is a breaking change — we should seriously consider it before we approach stabilization, and this might be suitable for adding.

https://github.com/fermyon/spin/blob/c0f2b3fd6ff5751772f9f90bbb25d017475f6e6e/crates/http/src/lib.rs#L351-L361

In the meantime, we could consider adding the information in the way @ecumene suggested — https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

radu-matei avatar May 11 '22 02:05 radu-matei