On the bright side, being born is a death sentence! :)
On a more serious note, I suppose moderation is key. Sunlight as much as easily doable, sunscreen only on the face (and check between physical and chemical sunscreen), and if you’re still deficient then take a supplement.
This is not possible in every country. In dark (e.g. northern european) countries, even children, who spent a significant time outdoors, need vitamin D supplementation.
Sunscreen is an endocrine disruptor
Vitamin D is an endocrine disruptor
You're fucked.