Exercise as a trigger is common. Potentially, dehydration, changes in blood pressure, blood sugar levels, mineral balance, muscle tension, homonal swings, or other exercise related phenomenon can be triggers.
I saw a documentary about a competative weightlifter whose migraines abated when she took a break from lifting. But she insited on returning and the migraines returned. (Not the focus of the film, though)
I'd encourage you to meet with a trainer and see how you can enjoy the gym and meet your goals with different exercises.
And to be sure to mind your water, food, minerals etc.
You'll find many posts here about how "pushing through" or ingnoring known triggers just isn't worth it.
Alternatively, the trigger might be something besides the exercise itself. Such as the gym lighting, music or smells. Wearing earbuds is a trigger for some. If you always consume a certain food or drink in association with your workouts, those might be triggers. Perhaps, you encounter more pollution/traffic on gym days.
There are soooo many things that can be triggers, but, yes, just exersice can be the culprit. Ofta
I get exercise induced migraines. Personally, I have found the only solution for me is to exercise at much lower intensity than I once did and still love. I also stand a better chance of avoiding migraine when I stay hydrated, take magnesium and potassium, avoid over heating, and stop at the slightest hint of feeling "off" (which even then is often too late).
Do talk to your healthcare team about your concerns.
The app Migraine Buddy can be helpful in tracking and distiguishing multiple triggers. (So like one day you change one thing about your gym experience and something else another day).
If you search at this site you'll find many posts about migraine and exercise.
Best wishes in finding the workout that will work for you without migraine!