Preheat your oven to 400°F. Prepare a 9x13-inch baking dish by coating it with nonstick spray.
Place the baguette slices on a baking sheet and toast for 8-10 minutes until golden and crispy. Set aside.
In a large Dutch oven, melt the butter and add the sliced onions, salt, pepper, thyme leaves, and bay leaf. Cover the pot and place it in the oven. Cook the onions for 1 hour, then remove the pot and stir, making sure to scrape the bottom and sides.
Return the pot to the oven, leaving the lid slightly open, and cook for another hour. Stir the onions again, and if they are not yet caramelized, cook for an additional 30 minutes.
Once the onions are a deep golden brown, transfer the pot to the stove over medium-high heat. Carefully remove the bay leaf.
Pour in the sherry, beef broth, and chicken broth, stirring constantly until it comes to a boil and slightly thickens, about 4-5 minutes.
Layer half of the toasted bread in the casserole dish, spread the onion mixture evenly over the top, and add the remaining bread slices. Sprinkle the shredded Gruyère cheese on top and cover with foil.
Bake at 400°F for 30 minutes. Then, remove the foil and switch the oven to broil. Broil for 3 minutes until the cheese is bubbly and golden. Keep an eye on it!
Garnish with extra thyme leaves before serving, if you like. Enjoy!