This is not terribly difficult; handle it in the factory for that middleware, and/or create a factory for it, and/or create a delegator factory for it.
Probably the easiest route is to create a single delegator factory for such middleware, and then map it to any services you have that currently produce double-pass middleware. It would likely look something like the following:
use function Zend\Stratigility\doublePassMiddleware;
public function __invoke(Container $container, string $serviceName, callable $callback)
You would then attach it to the service within your configuration:
'dependencies' => [
'delegators' => [
\Blast\BaseUrl\BaseUrlMiddleware::class => [
'factories' => [
\Blast\BaseUrl\BaseUrlMiddleware::class => \Blast\BaseUrl\BaseUrlMiddlewareFactory::class,
The nice bit about this approach is you can re-use it for any service that normally returns double-pass middleware — and you’ll easily be able to grep through your configuration to identify double-pass middleware in order to determine dependencies you may want to re-think or replace.