Preheat the oven to 375°F (190°C) and grease a baking dish.
Layer the potatoes and onions in the dish, seasoning with salt and black pepper.
Make the cheese sauce by melting butter in a saucepan, whisking in flour and salt, then slowly adding milk until smooth.
Stir in the Cheddar cheese and mix until fully melted and creamy.
Pour the cheese sauce evenly over the layered potatoes and onions.
Cover with foil and bake for 45 minutes, then uncover and bake for another 15 minutes until golden brown.
Let it cool for a few minutes before serving. Enjoy!