https://kotlinlang.org logo
#ktor
Title
# ktor
a

altavir

02/21/2020, 8:45 AM
I am trying to migrate
plotly.kt
to newer ktor version and encountered a problem. I need to get a host name from request in order to send a data request to the same server but with different address. Previously I was using
call.request.host()
for that, but now for some reason on localhost it returns IP6 adress 0.0.0.0.0.0.0.0, which is not friendly with JS backward requests. Are there any better way to treat this situation?
c

cy

02/21/2020, 8:51 AM
Looks like it points to local address, you need an origin host,
call.rrquest.origin.host
a

altavir

02/21/2020, 8:52 AM
call.request.host() is just a shortcut for what you wrote
c

cy

02/21/2020, 8:52 AM
Note that it doesn't include port
a

altavir

02/21/2020, 8:53 AM
And I know about the port. Port is OK. I just found there is a change in behavior. It was working before.
I probably do not need the host address at all, since I am running everything inside the server, but I probably will need it in future.
c

cy

02/21/2020, 8:55 AM
Well, looks like we have it broken by pr
Use host header for now
When running behind a proxy, the forward headers feature should fix that as wll
a

altavir

02/21/2020, 8:56 AM
Thanks, did not think about that.
c

cy

02/21/2020, 8:57 AM
Btw, it's strange that you see zeroes, not something like ::1
s

spand

02/21/2020, 8:57 AM
Note that nginx will not forward that by default in some configurations.
a

altavir

02/21/2020, 8:57 AM
🤷‍♂️
plotly.kt is made for local visualization on the same machine, so in most cases it will use a localhost.
c

cy

02/21/2020, 8:58 AM
There are two headers that proxies usually set, we have two features for that
Ok
Could you please open an issue?
a

altavir

02/21/2020, 8:59 AM
OK, I will, but I am not sure what is the designed behavior.