Can we pass a hostname/IP address as a query string in a GET request in REST API

40 views Asked by At

If I have to pass a hostname or a IP address as part of a GET request, is it okay to do it as a query parameter? Will there be any security risks? The response of the GET request will depend on the input IP address. So passing the IP address as payload for a GET request is not probably a good design (Reference: HTTP GET with request body)

Eg: http://localhost:3000/1/192.167.1.2/

1

There are 1 answers

2
Remy Lebeau On

Nothing prevents you from specifying a Host/IP in the path or query portions of the url, if it is actually an input value that the server will use in a data query.

But, if you are trying to tailor the server to host multiple sites on a single IP and differentiate them by host names, then use the HTTP Host header instead.