You should fix your localhost, otherwise localhost is not a good model of production.
And you’ll end up forgetting to remove your “localhost specific code” and break productions security, since the code you are adding introduces a security vulnerability