The only example in Drupal core for a dynamic route depending on user saved data is a View with a page display and this takes a very long time to save. Views needs routes for contextual filters. Unless you have such a specific use case for content (please edit your question if you have one), the right way would be aliases. In the node edit form you can add only one alias, but you can add more in /admin/config/search/path. If you want that in one place you could alter the node edit form for multiple aliases.
If you don't want to create each alias by hand and the paths have a pattern you can use a path processor. You can create the scaffolding with drush
drush gen path-processor
and put the regex pattern in the inbound method:
/modules/custom/mymodule/src/PathProcessor/PathProcessorMymodule.php
<?php
namespace Drupal\mymodule\PathProcessor;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Path processor to remove a prefix.
*/
class PathProcessorMymodule implements InboundPathProcessorInterface {
/**
* {@inheritdoc}
*/
public function processInbound($path, Request $request) {
return preg_replace('#^/(author|supporter)/#', '/', $path);
}
}
You can get the original path later with
\Drupal::request()->getPathInfo()
or you could store the prefix in a service property before removing it to make it globally available.
If your checks produce rendered output then add the url.path
cache context.