I think this isn't great advice for everyone.
I'm 31 and actually, I've gone through phases and got bored and miserable about my job (I have ADHD and this happens easily). The thing I've found that helps is to keep things fresh, and find a job where you care about the company and product and have more flexibility in what you do and are still learning and keeping stuff interesting. I'm learning Rust at the moment because I know just doing front-end stuff (I've done all kinds of stuff in the past 12 years, but at the moment front-end is what gets the money). Even doing more jobs using React Native and opening up the world of app development has kept thing interesting.
Also maintaining a work life balance, aggressively enforcing flexibility (I was straight up with my new employer that some days I am useless and just want to go for a walk, but I will work hard enough on the days my brain wants to play ball, that it won't be an issue).
Burnout is a lot easier in corporates because there is less flexibility and you are so removed from the people at the top and are much more of a cog in a machine, there are arbitrary seeming rulebooks because they require consistency, and that is demoralising for individuals. Basically the more corporate a company is run, the less I like it.
Once I lose interest I'll end up doing stuff that will end up in my being let go which has happened a couple times in my career, so maintaining interest and keeping things fresh in whatever way is absolutely imperative. Also the product I'm building is a factor for me - I've worked at companies where despite having a good team, what they're building is so mundane and dull I can't force myself to be excited by it.
Remember what excited you about your field and why you got into it. If that was purely money then yes, previous advice is all you can do really, but if it was a passion for your field, then keep feeding the fire and reigniting that passion by whatever means necessary. Sometimes you need a break, sometimes you need a change, sometimes you need something new.