Fix http route not working

This commit is contained in:
Lim Chee Aun 2023-08-08 17:29:04 +08:00
parent 58c6b6349c
commit 3d458826cf

View file

@ -1,3 +1,4 @@
import { useLayoutEffect } from 'preact/hooks';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import Link from '../components/link'; import Link from '../components/link';
@ -7,18 +8,34 @@ export default function HttpRoute() {
const location = useLocation(); const location = useLocation();
const url = location.pathname.replace(/^\//, ''); const url = location.pathname.replace(/^\//, '');
const statusURL = getInstanceStatusURL(url); const statusURL = getInstanceStatusURL(url);
if (statusURL) {
window.location.hash = statusURL + '?view=full'; useLayoutEffect(() => {
return null; if (statusURL) {
} setTimeout(() => {
window.location.hash = statusURL + '?view=full';
}, 300);
}
}, [statusURL]);
return ( return (
<div class="ui-state" tabIndex="-1"> <div class="ui-state" tabIndex="-1">
<h2>Unable to process URL</h2> {statusURL ? (
<p> <>
<a href={url} target="_blank"> <h2>Redirecting</h2>
{url} <p>
</a> <a href={`#${statusURL}?view=full`}>{statusURL}</a>
</p> </p>
</>
) : (
<>
<h2>Unable to process URL</h2>
<p>
<a href={url} target="_blank">
{url}
</a>
</p>
</>
)}
<hr /> <hr />
<p> <p>
<Link to="/">Go home</Link> <Link to="/">Go home</Link>