I initially assumed I was doing something wrong but after a week or so experimenting with simple test cases I could not get it to work. Maybe it works fine on Linux and Mac but not Windows.
We should probably have a weekly HN column with that title.
Might be better than nothing I guess, but on the long term you'd need to add the port in settings and request the permission for localhost+port dynamically? But that's got another issue, e.g. last time I tried it [0] for my extension, Firefox didn't support dynamic URL permissions for URLs with ports.
[0] https://github.com/karlicoss/grasp/blob/f24378ebae68c22bea03...
But actually 127.0.0.1 seems unaffected:
$ host 127.0.0.1.xip.io
127.0.0.1.xip.io has address 127.0.0.1
$ host 192.168.1.1.xip.io
# no resultI doubt it is at all common in end user environments, but unbound for instance can be configured to prevent local IPs from being resolved in other domains. It's a good practice to follow in a datacenter environment if you're connecting out to hostnames you resolve from DNS you don't control.
An example of how we use this communication channel is preventing both our extension and desktop apps from showing notifications on the same computer. Our apps are all about notifications so this would get unacceptable very fast. We ping our local desktop app via localhost to see if it can manage the notification, and show it with our extension if it isn't running.
Maybe if we limit it to just the local port we use? Seems like it can't hurt to try that too.