Skip to content

Commit

Permalink
Do not follow redirects on local linkup server (#53)
Browse files Browse the repository at this point in the history
This does not make it work when using a cloudflare worker / tunnel. 

The wasm client of reqwest does not support their "redirect policies"
yet:

https://github.com/seanmonstar/reqwest/blob/master/src/wasm/client.rs
  • Loading branch information
ostenbom authored Dec 21, 2023
1 parent bf31338 commit c4b2c65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion linkup-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linkup-cli"
version = "0.2.3"
version = "0.2.4"
edition = "2021"

[[bin]]
Expand Down
12 changes: 10 additions & 2 deletions linkup-cli/src/local_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async fn linkup_ws_request_handler(
let extra_headers = get_additional_headers(&url, &headers, &session_name, &target_service);

// Proxy the request using the destination_url and the merged headers
let client = reqwest::Client::new();
let client = no_redirect_client();
headers.extend(&extra_headers);
headers.remove(LinkupHeaderName::Host);

Expand Down Expand Up @@ -193,7 +193,8 @@ async fn linkup_request_handler(
let extra_headers = get_additional_headers(&url, &headers, &session_name, &target_service);

// Proxy the request using the destination_url and the merged headers
let client = reqwest::Client::new();
let client = no_redirect_client();

headers.extend(&extra_headers);
headers.remove(LinkupHeaderName::Host);

Expand Down Expand Up @@ -250,6 +251,13 @@ async fn always_ok() -> impl Responder {
HttpResponse::Ok().finish()
}

fn no_redirect_client() -> reqwest::Client {
reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.unwrap()
}

#[actix_web::main]
pub async fn local_linkup_main() -> io::Result<()> {
env_logger::Builder::new()
Expand Down

0 comments on commit c4b2c65

Please sign in to comment.