hugo server -b localhost/foo/ 
Also, in general, setting canonifyURLs = true works better in my experience when dealing with baseURLs with subdirs.
There was a recent thread where @it-gro and I got into indepth analysis of relURL, absURL, canonifyURLs with such baseURLs.