You will have to configure a service endpoint to allow traffic from the GatewaySubnet to the Cosmos account.
When a service endpoint for your Azure Cosmos DB account is enabled on a subnet, the source of the traffic that reaches Azure Cosmos DB switches from a public IP to a virtual network and subnet.
The steps with screenshots are here
Do let us know if you have any further questions.
----------
If an answer is helpful, please "Accept answer" or "Up-Vote" for the same which might be beneficial to other community members reading this thread.