The setup is absolutely so, as Google recommends:
www.example.com has a media query for narrower display sizes and redirects users to m.example.com, if display becomes narrower, as setting. Both versions are tied to each other with alternate<->canonical.
The fun begins with fetching as Google in the search console.
What happens, if you fetch as Google www.example.com and select a mobile user agent for fetching? Damn right - the googlebot stands on www.example.com and is not redirected to m.example.com. Why? Because googlebot has no display width!
But the same could happen during the crawling procedure in the wild web: the bot comes with mobile user agent to www.example.com and gets wrong site version and content, because it isn't redirected properly to m.example.com.
Now the million bucks question: how to redirect gooblebot with mobile user agent, if the general redirect logic isn't based on explizit user agent identification, what is absolutely recommended.
media-query
, you mean aCSS media-query
? Because it that case, it means that your redirection happens on the client-side and thus the google bot would probably never get the redirect even if it had a display width.