To me, the solution is simple: use a single source (some IDL format) to define objects at API boundaries and have your frontend and backend use it.
It will make it a lot harder to return wrong types from your calls. Personally, I like gRPC + Protobuf.