mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
different redirect approach
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user