SOLVED
In the end, it was a proxy/cache issue, I assume. After fixing the proxy directives' placement in nginx config, disabling nginx caching, rebuilding and reloading nodebb and switching themes and back again, the issue was no longer there. After reenabling caching, everything was still ok. In case it should become clearer what caused the issue, I'll update this answer.
For the JS issue, refer to https://community.nodebb.org/topic/16031/template-js-not-executed .
Thanks.