In a wide pan, heat olive oil over medium heat. Add the onion and sauté for 3–4 minutes. Add the red pepper and courgette, and cook until softened (about 5–6 minutes). Stir in the garlic if using.
Pour in the pulped tomato and add a splash of water if needed. Add olives, salt, pepper, and chili flakes if desired. Simmer uncovered for 10 minutes to let the sauce thicken slightly.
Nestle the cod fillets into the sauce, spooning a little over the top. Cover and cook gently for 6–8 minutes, or until the fish is just cooked and flakes easily.
Scatter torn basil over the top. Serve over soft polenta or pasta, spooning the sauce around the cod.