Of course if the thing could just run directly off wall power like you suggested, this wouldn't be a problem.
Most of the devices also have a custom ROM and are rooted, and using the ACCA app I restrict charging to a maximum of 80% battery capacity.
I had a Samsung Note 5 (released in 2015) that only went spicy maybe 6 months ago. I have a Samsung S9 and a Nokia 6.1 that are both still going strong with fairly recent versions of LineageOS. Both are 2018 phones, so around 6.5 years old (old for phones, but shouldn't be 'electronically' old).
I used this method too but then LineageOS merged the functionality in a few years ago and it works perfect.
I have a Nokia 6.1 as well but my oldest continuous use device is a Oneplus 8T used to provide hotspot to a location 24/7/365.
You can also buy dummy batteries for certain models online.
1. Heat
2. Being fully charged all the time
Recording video consumes a considerable amount of power, leading to heat. The display less so, unless you're operating at maximum brightness all the time.
#2 is what killed my Pixel 3 after only about 2 years. Once I started working from home, I had a bad habit of letting my phone sit on the charger all day and after about 3 months of WFH the pillow got spicy.
For a phone that's going to be repurposed as a server, I wonder if it'd be worthwhile to open the case and attach a heat sink to the battery.
If your phone won't do that, you can use a smart power switch. Some mentioned to simply have it on a timer, but if you wanted to get fancier, you could use IFTTT to toggle it on/off based on battery percentage. I'd likely make it turn on at 40% battery and off at 60%.