Serve domain.APP from domain.COM/SUB

The situation is as follows:

domain.com is the primary domain hosted at Hoasted.

domain.app is the domain for the app hosted at Vercel

Now what I want is to serve domain.app from domain.com/app

Because the domains are on 2 separate servers I can’t use Alian domain with a htaccess redirect. I read something about the workers from Cloudflare.

How can I get the .app domain to the .com/app ? Im also happy with another work around.

You could build something around this example.

Thanks for your reply that looks advanced code for me. I can ask my developer to take a look at.