For the sturdiest fix simply screw one or more 2 inch thick.
How to fill gap between mattress and bed frame.
Bamboo bed bridge twin to king converter kit wide bed gap filler to make twin beds into king adjustable 2 inch wide mattress connecting strap and 4 bed sheets fasteners storage bag included 4 1 out of 5 stars 138.
Place the structure between the mattress and the foot board and enjoy.
Then use the area for under bed storage boxes and cover with a board and put a handle on it.
To make a cover for storage.
Secure the two longer pieces to the remaining short piece with 2 1 2 wood screws.
Place the hook into the next available groove.
Put the pillows on that area which now makes the bed longer.
Push the frame back against the headboard.
Block the gap when a new mattress is just not in the budget consider bridging the gap at least until you can afford a new mattress.
Then attach the right half to the left half using either pocket hole screws or angle brackets.
Adjust the bed frame so that it is wider than the headboard by unhooking it at the middle and widening the frame.