Melt the butter in a large pot over medium heat. Add the onions, garlic, bay leaves, thyme, salt and pepper and cook until the onions are very soft and caramelized, about 45 minutes. Add the wine, bring to a boil, reduce the heat to medium and simmer until the wine has almost evaporated, about 25 minutes. Discard the bay leaves and thyme sprigs.
Dust the onions with the flour and give them a stir. Reduce the heat to medium–low and cook for 2 minutes. Now add the beef broth, bring the soup back to a simmer, and cook for 15 minutes. Season with salt and pepper, to taste.
Preheat oven to 400 degrees F. While the soup is simmering, arrange the baguette slices in single layer on baking sheet. Bake for 4-6 minutes, until the bread is toasted and golden around the edges. Remove from oven and rub them with some garlic, if desired.
Switch the oven to the broiler. When you're ready to eat, place your oven-safe bowls or crocks on a baking sheet. Ladle the soup into the bowls, then top with a baguette slice (I cut it into bite size pieces before putting it on top of the soup) and your desired amount of cheese (I used about 1/3 cup grated cheese for each).
Carefully place in oven and broil for 2-4 minutes until the cheese is melted and bubbly. Remove and serve immediately (use caution when serving, as the bowls will be HOT). Enjoy!