Problem of URLs with internal links with ‘base href’

I’ve got a website with includes the following directive in the HEAD section:

<base href="https://foo.com" /> 

Now, I want to create internal links to sections within the page ‘https://foo.com/product/name-of-the-product’

<a href="#photos">Photos</a> 

But, instead of linking to ‘https://foo.com/product/name-of-the-product#photos’, it links to ‘https://foo.com/#photos’.

Any tip to fix this? Thank you.