In a large saucepan or soup pot, heat the olive oil over medium-high heat. Add the onions, shallots, leeks and season with salt and pepper. Cook about 20 minutes, stirring frequently, until caramelized meaning soften and golden brown. Add the thyme and bay leaves and cook for another 1-2 minutes.
Reduce heat and sprinkle the flour over the onions-shallots-leeks, stirring continuously for 1-2 minutes until absorbed. Add wine and bring to a boil. Reduce heat and simmer until liquid is reduced.
Pour in the hot stock or water, bring to boil, then simmer for around 20 mins until the vegetables are completely soft. Discard the bay leaves and season to taste.
Preheat the oven at 482°F (250°C).
Ladle the soup into individual heatproof serving bowls. Top with a slice of bread to each of them (to fit like a lid) and sprinkle evenly with cheese. Place them on a baking tray and transfer to the oven. Grill until golden brown no more than 3-5 minutes. Be careful not to burn it.
Serve immediately while the cheese is still bubbling.
Pair it with a fruity white wine like Viognier or Sauvignon Blanc.