I am getting 404 whenever I input the url manually.
Please help solve this problem.
1 Replies
Hello,
For those looking to just make their projects compatible with old URLs, you can force update any hash missing the leading "/". This is not the most elegant solution, but it solved it for me.
Add this to your index.js entry file:
const forceSlashAfterHash = () => {
let _hash = window.location.hash;
if (_hash[1] && _hash[1] != '/') {
window.location.href = window.location.origin + window.location.pathname + window.location.search + "#/" + _hash.slice(1);
}
}
forceSlashAfterHash();
window.addEventListener('hashchange', forceSlashAfterHash);
When the page loads or the hash changes, it checks for a leading "/" in the hash, and if not present, adds one.
I hope this will solve your problem...