different redirect approach

This commit is contained in:
SpikeHD
2022-06-11 15:19:38 -07:00
parent e71a73c19a
commit f327a54900
2 changed files with 15 additions and 11 deletions

View File

@@ -49,16 +49,20 @@ impl HttpHandler for ProxyHandler {
_context: &HttpContext,
mut request: Request<Body>,
) -> 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::<Uri>().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)

View File

@@ -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(
<React.StrictMode>
<App />
{/*<Test />*/}
{/* <App /> */}
<Test />
</React.StrictMode>
)