Find the nearest location and move to a target outside Navigation Mesh?

Hi!
I have a problem with the target outside NavMesh, when I let the NavMesh Agent move to the target outside of NavMesh, NavMesh Agent cannot move to that location. How can I move to a location closer to the target but still inside NavMesh

I know that the reason it is not moving is because the path is not valid.
How can I initialize a position closest to the target outside of NavMesh and NavMesh Agent can move to that position but it’s still inside of my currently NavMesh.