Backend Code only runs in Preview

To help identify the issue, try calling a simple backend function that just returns a hardcoded value. This way at least you’ll know if there’s an issue with the frontend/backend interface.

One thing to keep in mind is that when running in Preview, you are running as admin and not as a visitor.