luceos But no one has attempted it yet, as far as I know
I attempted something similar, but based on the user's preferences, and because of that I got stuck.
This seems to be possible in this case. You could bypass the need for middleware and use $_SERVER['HTTP_USER_AGENT']
to detect if it is the mobile version. As if anyone would like to do that, here is the code to conditionally override the default route: https://discord.com/channels/360670804914208769/360689644230410251/1203705940654821446.
There is a library for detecting device type: https://mobiledetect.net/.
If you modify get
method from the above Discord example, it should work (not tested):
public function get($key, $default = null)
{
if ($key === 'default_route') {
$detect = new MobileDetect();
$detect->setUserAgent($_SERVER['HTTP_USER_AGENT']);
// Set default route to /tags in the forum settings. This code will change default route to "All Discusions" if device type is mobile.
if($detect->isMobile()) {
return '/all';
}
}
return $this->repository->get($key, $default);
}