Breastfeeding and codeine

Has anyone else been prescribed codeine while breastfeeding? My doctor says it's safe but I'm seeing things all over the internet warning against it. I've tried other painkillers first and it's the only one that works. I had my gallbladder removed 1.5 months ago and I'm experiencing horrible pain 7/10 if I don't take medication (I'm currently waiting for results from other tests as they suspect something else is wrong). I'm just paranoid that it's going to affect my son :(

Edit: my doctor is also my son's pediatrician