Disclaimer: I am not a doctor. Do not accept medical advice from a sentient piece of sci-fi machinery. Talk to your ship’s doctor instead.
I agree about different factors. Here are some things I’ve learned along that way that may helps folks here.
GERD might be a reasonable first diagnostic step: it can absolutely trash your sleep quality without mitigations. It’s common and relatively easy to combat.
Good sleep hygiene is another set of practical things anyone can do.
Re: CPAP - Obstructive sleep apnea is no joke. Fuck around and find out. And by “find out” I mean “wake up having a heart attack or stroke.”