I am trying to make an Http request which needs to go through a proxy. I saw an answer referring how to do it with create-elm-app, but I am not using this and was wondering if there is an easy method of doing this? I have tried with the Via header (left down below to see the use I am going for), but that probably has nothing to do with it.
Do I need to use some kind of behind the scene trickery or is there a native way of doing it?
fetchUiElements : Cmd Msg
fetchUiElements =
let
baseUrl = "https://example.com/"
responseDecoder =
Json.Decode.field "data" Json.Decode.string
httpBody =
Http.jsonBody <|
Json.Encode.object
[ ("", Json.Encode.string "")
, ("", Json.Encode.string "")
]
in
Http.request
{ method = "POST"
, headers = [ Http.header "Via" "http://proxy.com:8888"]
, url = baseUrl ++ "getUiElements"
, body = httpBody
, timeout = Nothing
, tracker = Nothing
, expect = Http.expectJson FetchUiElements responseDecoder
}
Edit: For further clarification I want the same behaviour as this curl
curl -x "http://proxy:8888" -v https://endpoint/getstuff