I have a second house on my property where my Mom lives and I extended my internet and Dish network to her house using one of these: Wireless bridge
Not necessarily making a brand recommendation, but more of a concept recommendation. The instructions were not great on this one, sorta like they were written in another language then run through Google Translator. Got the job done but required some trial and error.
I would not use that, wifi bridges have came a long way since that was introduced. I would use a pair of directional POE wifi bridges, then add a basic wifi router running in accesspoint mode inside the second building. I am doing something like this with our shop building on the family ranch, which is about 1,000 feet from the main house, and am getting effective speeds up to about 60-80 mbps there when Starlink is getting around 130 mbps at the main house.
I was initially using these https://smile.amazon.com/gp/product/B072Y5S8YX/ with one of these little access points inside the metal shop building https://smile.amazon.com/gp/product/B0167N0B70 until the shop building took a direct lightning strike frying the equipment on that end, I replaced the stuff at that end with an omni directional extender https://smile.amazon.com/gp/product/B08C4QCWC5 and then upgraded the unit at the house end with a Micro-Tik POE directional unit when the unit on that end became unstable.
Your experience and mine differ then running a 5.8ghz link between two buildings about a thousand feet apart in heavy (torrential) rain using directional POE wifi bridges such as this one https://smile.amazon.com/gp/product/B072Y5S8YX/
I use something similar on the family ranch to reach the shop buildings located about 1000 feet / 300 meters from where the Starlink is mounted at the house. I used these https://smile.amazon.com/gp/product/B072Y5S8YX/ they are limited to 100 mbps on the hardware ethernet port, so are a bit slower than Starlink on a fast day, which works ok for me.
I am doing something very similar using a TP-Link RE450 to convert from wifi to ethernet, then household WavLink Mesh, which feeds a wifi bridge to an outbuilding about a thousand feet away, using a pair of these https://smile.amazon.com/gp/product/B072Y5S8YX/ Works well except in heavy rain where I get dropout on the wireless link before starlink drops out.
The 40 meters you describe is well within the max length of the cable (at least for CAT 5 & 6). The connector connecting the two segments together may be introducing loss. Try replacing that first then if it does not clear up, try another port on the switch end and/or a different Ethernet cable. If you can swing it go fully wireless with this or something similar: https://www.amazon.com/QW-CPE5450-Wireless-Bridge-Point/dp/B072Y5S8YX/
Wireless will need a clean line of sight.