The code snippet above was used in an attempt to refresh the page when the back button is pressed, but it only works inconsistently in Chrome. The issue seems to be that despite correctly detecting the back button press, the page does not always refresh as intended. This problem occurs mainly in a production environment, while occasionally working fine locally.
@HostListener('window:beforeunload', ['$event']) onPopStateBack() {
console.log("Back Button detected!");
window.location.reload();
}
@HostListener('window:popstate', ['$event']) onPopState(event: any) {
console.log("Back Button detected!");
window.location.reload();
}