@riking implemented a proper fix for this. This can be closed.
https://github.com/discourse/discourse/pull/3753