What is the ruling on
the yellow discharge during nifaas and throughout the forty days (after
the birth)? Should I pray and fast?

Praise be to Allaah.

Whatever discharge is passed by a woman following
childbirth comes under the same rulings as the blood of nifaas, whether it
is regular blood or a yellow or brownish discharge, because it is within the
usual timescale of nifaas, until the forty days are over. Whatever comes
after that, if it is regular blood and there have been no interruptions in
the flow, then it is the blood of nifaas, otherwise it is the blood of
istihaadah (vaginal bleeding that is not menstrual or nifaas), etc.