spin
spin copied to clipboard
Access client IP from SDK
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
@radu-matei Could/should we add it to the request
record in http-types.wit
, or is that set in stone?
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