Of course, it is fine but you also need to make sure they are not contaminated with toxic chemicals such as pesticides or do not secrete toxins that can harm your fish.
I have fed crickets, june bugs and the occassional moth and fly to my fish and have never seen any sign of a problem. Insects are an important part of the diet of most fish that we keep in aquaria.