Earlier quoted context omitted.
Older devs even with many years experience have it harder. That’s my own experience.
Yeah I mean I plan to be consulting or a CTO or something by that age. Unless you are crazy specialist I think you need to branch out into strategy or have enough reputation and connetions to earn silly money freelancing.
I don't known what it means "older devs have it harder". I am a valued contributor, and if something bad would happen I have a pocket full of leads where to find next gig.
You have to maintain your career - nobody is going to do that for you. So yes, you have to figure out how to become a valued contributor.
Make sure your CV communicates you are "smart and gets things done" and you are set, more or less.
Perhaps software engineering is a bit more fragile than other more professional fields as there are lot of young uneducated employees who can be abused and exploited by unscrupulous employers. But generally you learn to identify those, and with a good CV of years of successful projects, you can find agreeable employment in most market situations.