paul in AZ
I built something like that in cherry for a TV stand. That shelf isn't very wide and isn't going to move all that much.
I attached an elongated block to the inside of the end rail, cut the notch for the legs with a hair of expansion space and sat the shelf on the block so it sits flush with the rail. That little gap at the inside of each leg is barely noticeable.
I also attached the shelf with a single screw at it's mid portion -just because.