Can you expand further? Are you saying you hard-codes the realm name in the custom page zip file? The realm & role names are 100% independent of each other; changing one should not break the other. (Unless you have something(s) hardcoded that you need to modify.)
Ok, i didn't realize you had tried to work with them in the past. Can you post your custom page, or a modified sample of it to remove any confidential information if desired, and instructions on how to try & replicate? If you are not comfortable with that, that is fine; can you give step by step instructions for me to try & replicate against here?