After GraphHopper imports the OSM data it no longer stores the OSM node and way IDs so they are not accessible when routes are calculated (or map-matching is used).
However, this feature is requested quite frequently and some community members have already worked on doing this in their own forks. You should use the forum’s search capabilities and specifically take a look at these discussions:
And maybe it would be useful if you explained why you want to retrieve the OSM IDs and what you intend to do with them.