In any game the balance decision often comes down to two solutions:
1.Make melee attacks more powerful to balance out projectile/AoE attacks range advantage.(e.g. faster attack with more damage, bonus effects/stun/etc).
2.Allow defense against projectile/AoE attacks to negate most of its damage.(e.g. damage decay over distance/time, resistances/armor effects, chance to dodge any attack, shielding aura/effects(e.g. Dark Swarm in Starcraft)).

The problem can also be solved ultimately by removing the melee from the game or making melee last-resort option.
Ranged attacks and Area of Effect skills/spells are far more diverse tactically and allow many more options for the player:
Melee limits units/player/entities to chasing down enemy units one by one.