Back button not working


I have a page with a URL of /cars. I have some onpage live filters on this page and this uses the following to update the page URL:

history.pushState({}, '', config.url)

This updates the URL correctly to something like /cars?make=12.

If I then click on a resulting filtered car I get a new page with a URL like /cars/34 and the issue I have is that when I click the Back button in my browser, the browser shows the previous URL but the page doesn’t change.

Any ideas how I can fix this?