Yes, thankfully, there is a way to detect the fakes. It's really about the level of detail that you look at. An untrained eye probably would not be able to tell the difference, but to someone who looks at the real deal day in and day out, the fakes are often very very easy to spot.
Coin nerds study the real ones in excruciating detail - to the point that people catalog not only the various dies that were used to strike various coins but the states of those dies (i.e. Early die state == pristine coins. Middle die state == a crack or chip might have started to form which presents as a raised line or spot on the surface of struck coins. Late die state == chunks of the die might be missing.). This is often done through reverse engineering -- examining enough examples of struck coins to identify differences in the the dies used. The dies themselves can be identified through unique markers -- a polish line here, the exact positioning of a letter, a microscopic defect, etc.
So when you are able to identify the known dies, a counterfeit will stick out like a sore thumb. And if it was made from a cast copy of a known-good coin, then those will have their own telltale giveaways.
In short: The counterfeits will always have subtle differences.