Link from post to plugin route leads to 404

I have written a plugin that appends a route like this:


after_initialize do
  load File.expand_path('../app/controllers/plugin_controller.rb', __FILE__)
  Discourse::Application.routes.append do
    get '/plugin' => 'plugin#index'


export default function () {
  this.route('plugin', { path: '/plugin' });

A link to https://discourse.sld.tld/plugin throws a 404 when clicked in a post. Opening https://discourse.sld.tld/plugin in the browser or opening the link in a new tab/window works.

What can I do to make the link in the post work?

Any help would be appreciated.