Created
November 21, 2024 15:15
-
-
Save elisherer/420810ac48775e86e400258aa8a3a030 to your computer and use it in GitHub Desktop.
Fix for client routing in github pages (SPA)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Website</title> | |
<!-- client router fix for github pages --> | |
<script type="text/javascript"> | |
location.replace(`${location.origin}?client_redirect=${encodeURIComponent(location.href)}`); | |
</script> | |
<!-- client router fix for github pages --> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Website</title> | |
<!-- client router fix for github pages --> | |
<script type="text/javascript"> | |
const cr = new URLSearchParams(location.search).get('client_redirect'); | |
if (cr) { | |
const u = new URL(cr); | |
history.replaceState(null, null, u.pathname + u.search + u.hash); | |
} | |
</script> | |
<!-- client router fix for github pages --> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment