I want to make Google Maps or OpenStreetMap (OSM) a base map/layer on Geoserver that can be published, without having to download the entire map, for example by using the xyz tile url service like so:
Google Satellite : https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
or,
OSM : https://a.tile.openstreetmap.org/{z}/{x}/{y}.png
Is there any solution regarding this problem?
GeoServer only provides the capability to cascade WMS, WMTS and WFS services. It would be possible to write similar code to cascade OSM tiles but I would expect this would violate the Google ToS (iirc you must not scrape their tiles).
I think MapProxy can do what you ask for, at least for OSM tiles.