1
0
Fork 0

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