Sometimes you may get a 404 error with custom rewrite endpoints. This usually happens because you use the same query variable as other rewrite rules. For example, if you have a WooCommerce site, it already registers the /product/ variable. So you can’t use it in your own code. You need to change the WooCommerce variable or use a different one in your functions.