When I click the Add to Compare button from the category page, it redirects to 404 error page and the product is not added to the compare list.
The url it leads is mywebsite/catalog/product_compare/add/?product='PRODUCTID'&uenc=aHR0cHM6Ly9wYWdlNDA0LmV1L3JvdXhh&form_key=VhN2bBczF6mI8iGK
However, the compare button on the Product Details page works fine. It refreshes the page, displays a message 'Product is successfully added to compare' and the product is added to compare.
I am using Magento 2.3.0 with Porto theme. I tried changing to Magento Black and Luma themes but the problem was not solved.
How can I fix this?