Many boats have tanks under the cockpit area, and not all have these storage areas fully isolated from the cabin space. Obviously the tank must be secured, and all fittings tight.
A temptation may be to mount the fill immediately above the tank on the cockpit floor. This does work, has been done, but it seems to me that the chances of water intrusion are higher (say, if a cockpit drain plugs while the boat is unattended), and any spillage will be underfoot and a slipping hazard at least. If you must do this, try to have thefiller on a slightly raised boss to protect the fill from standing water in the cockpit.
Vent the tank outboard in such a way that it cannot spill
fuel if you heel over with a full tank.
Keeping the tank low in the boat helps maintain the CG, getting away from temporary tanks aft in the cockpit will help trim and reduce pitching as well.
I did this on a boat years ago, same situation, and managed to shoehorn a tank under the cockpit - it worked fine. The vent ran out to the transom, high near the centerline.