From f327a5490067dc78a233278f64b27f5db4a3d7c0 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sat, 11 Jun 2022 15:19:38 -0700 Subject: [PATCH] different redirect approach --- src-tauri/src/proxy.rs | 20 ++++++++++++-------- src/index.tsx | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/proxy.rs b/src-tauri/src/proxy.rs index 164e001..6e4acca 100644 --- a/src-tauri/src/proxy.rs +++ b/src-tauri/src/proxy.rs @@ -49,16 +49,20 @@ impl HttpHandler for ProxyHandler { _context: &HttpContext, mut request: Request, ) -> RequestOrResponse { - // Get request URI. let uri = request.uri().to_string(); - let uri_path = request.uri().path(); - - // Only switch up if request is to the game servers. + if uri.contains("hoyoverse.com") || uri.contains("mihoyo.com") || uri.contains("yuanshen.com") { - // Create new URI. - let uri = format!("https://{}{}", SERVER.lock().unwrap(), uri_path).parse::().unwrap(); - // Set request URI to the new one. - *request.uri_mut() = uri; + let mut res = Response::builder() + .status(302) + .body(Body::default()) + .unwrap(); + + res.headers_mut().insert( + http::header::LOCATION, + http::HeaderValue::from_str(&format!("https://{}", SERVER.lock().unwrap())).unwrap(), + ); + + return RequestOrResponse::Response(res); } RequestOrResponse::Request(request) diff --git a/src/index.tsx b/src/index.tsx index c43546b..b3071ac 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client' import './index.css' import App from './ui/App' -// import Test from './ui/Test' +import Test from './ui/Debug' const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement @@ -11,8 +11,8 @@ const root = ReactDOM.createRoot( root.render( - - {/**/} + {/* */} + )