Melt the butter in a large pot over medium heat. Add the onions, garlic, bay leaves, thyme, and salt and pepper and cook until the onions are very soft and caramelized, about 25 minutes.
Add the wine, bring to a boil, then reduce the heat and simmer until the wine has evaporated and the onions are dry, about 5 minutes. Discard the bay leaves and thyme.
Dust the onions with flour and stir. Turn the heat down to medium low to avoid burning the flour, and cook for 10 minutes to cook out the raw flour taste.
Add the broth, bring the soup back to a simmer, and cook for 10 minutes. Season, to taste, with salt and pepper.
When you’re ready to eat, preheat your broiler. Arrange the baguette slices on a baking sheet in a single layer. Sprinkle the slices with the Gruyere and broil until bubbly and golden brown, about 3 to 5 minutes.
Ladle the soup in bowls and float several of the Gruyere croutons on top.