mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
different redirect approach
This commit is contained in:
@@ -49,16 +49,20 @@ impl HttpHandler for ProxyHandler {
|
|||||||
_context: &HttpContext,
|
_context: &HttpContext,
|
||||||
mut request: Request<Body>,
|
mut request: Request<Body>,
|
||||||
) -> RequestOrResponse {
|
) -> RequestOrResponse {
|
||||||
// Get request URI.
|
|
||||||
let uri = request.uri().to_string();
|
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") {
|
if uri.contains("hoyoverse.com") || uri.contains("mihoyo.com") || uri.contains("yuanshen.com") {
|
||||||
// Create new URI.
|
let mut res = Response::builder()
|
||||||
let uri = format!("https://{}{}", SERVER.lock().unwrap(), uri_path).parse::<Uri>().unwrap();
|
.status(302)
|
||||||
// Set request URI to the new one.
|
.body(Body::default())
|
||||||
*request.uri_mut() = uri;
|
.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)
|
RequestOrResponse::Request(request)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client'
|
|||||||
|
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import App from './ui/App'
|
import App from './ui/App'
|
||||||
// import Test from './ui/Test'
|
import Test from './ui/Debug'
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById('root') as HTMLElement
|
document.getElementById('root') as HTMLElement
|
||||||
@@ -11,8 +11,8 @@ const root = ReactDOM.createRoot(
|
|||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
{/* <App /> */}
|
||||||
{/*<Test />*/}
|
<Test />
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user