I would consider doing the following:
Replace the damaged rail with a piece of wood of similar species and dimensions. Or, if the existing rail is solid wood, repair the rail using a shorter piece of new timber using a scarf joint. If the existing rail is some sort of composite/laminate/chipboard, it likely may not be feasible to repair in this way.
Your existing rail looks like it might be some sort of composite with a complex cross section - but the replacement or repair part only needs to look the same on the outside and make contact with the other parts supported by the original rail. If you are just repairing the end you may not need to make an exact match in areas that don't show and don't support anything.
Drill it to accept the bolt you have, or just screw on a sturdy L plate
(sometimes sold as mending plates)
The metal bolt and nut you have are typical of flat-pack furniture. You just have to drill two suitable holes that meet and that start in the right places. This shouldn't be too hard.