Gaining too much weight

My midwife told me I've gained too much weight. I'm eating pretty well ect and I just feel like it's packing on and I can't stop it bloodwork, glucose, blood pressure are all perfect. Now I feel so fat, I'm almost 27 weeks and I started at 138. I'm 171 now🙈 I'm usually comfy at around 145-150 but had just lost weight from a second miscarriage. Have any of you gained this much and are ok? Is your Dr saying lay off the cookies? Thanks, just feeling chubby and like I haven't eaten correctly :(