Amine’s solution helped me come up with my own. Leaving it here in case it’s useful for someone else:
<script>
$(document).ready(function() {
$('a').each(function() {
var old_url = $(this).attr('href');
var current_domain = document.location.hostname;
if (old_url.includes("https://domain.com/") || old_url.includes("https://www.domain.com/")) {
var new_url = old_url.replace(/https:\/\/(www\.)?domain.com\//, "https://" + current_domain + "/");
$(this).attr('href', new_url);
}
});
});
</script>
This way there’s no need to add an attribute to the link. This will catch all domain.com and www.domain.com occurrences and replace them with the current host, like your-project.weblow.io.
When the site is ready to launch you can safely remove that code.
Hope it helps!