Melt butter in a large pot over medium heat. Add sliced onions and salt, cooking until onions are caramelized, about 30-40 minutes, stirring occasionally.
Sprinkle flour over caramelized onions, stir and cook for 2 minutes.
Pour in white wine to deglaze the pot, scraping up any browned bits from the bottom. Allow wine to reduce for about 5 minutes.
Add beef broth, bay leaf, and thyme. Bring to a simmer and cook uncovered for 30 minutes.
Preheat oven to 400°F. Arrange baguette slices on a baking sheet and toast in the oven until golden, about 5-7 minutes.
Place toasted baguette slices on top of the soup in oven-safe bowls, sprinkle generously with shredded Gruyère cheese.
Broil in the oven until cheese is melted and bubbly, about 2-3 minutes. Serve hot.