Neither option is satisfactory. Please come up with a solution for this, e.g. by making ! ids routable.
another workaround could be to put the routable server name in the permalink as a separate field - e.g. https://matrix.to/#/!cURbafjkfsMDVwdRDQ:matrix.org/$1487464117757368aDcvx:matrix.org?hs=matrix.org or something.
I agree this sucks. The current implementation assumes your local HS knows about the room already.
Alternatively, making the server routable in the room ID might be preferable - we should already be able to get enough uniqueness in the !prefix if we try hard enough (e.g. by including origin server there....)
Also consider switching to # aliases until a better solution can be achieved. Room ! IDs are definitely unroutable now, whereas individual # aliases might become unreachable in the future.
Is there something that prevents a server from just trying known servers? I mean if one of your contacts has sent you a link, then your server knows their server, and they probably are in that room. Synapse won't know which server you got the link from (unless it looked in the db but this would only work in unencrypted rooms), but it could just try all of them, maybe sorted by some combination of latest communication/amount of common rooms/etc.
The only thing I can come up with that makes this kind of bad, is that you would leak to other servers that some user on your server want's to access a room with that ID. To avoid leaking the room ID, synapse could just salt and hash it.
Short screencast:
https://matrix.to/#/!gTQfWzbYncrtNrvEkB:matrix.org/$15345347813198TsVFQ:mle.party
FYI, this also breaks the "Rejoin" button for people with a personal homeserver, as Riot tries to rejoin the room via its room ID. #7094
The stop gap for this has been merged: https://github.com/matrix-org/matrix-react-sdk/pull/2250
Leaving this open for "we can do better".
Most helpful comment
Also consider switching to # aliases until a better solution can be achieved. Room ! IDs are definitely unroutable now, whereas individual # aliases might become unreachable in the future.