Is there anything simmilar to res.redirect but in normal JavaScript?

I’m trying to make a re-director with plain JS (https://example.com/?ABCD -> https://example.org/t/ABCD), it works fine but when I use it with image urls, the image won’t be shown when put into Discord, Twitter, etc. Then I tried to use Express’ res.redirect and it did work.
Can you do anything simmilar to that but in normal JavaScript? I’ve tried this:

let url = `https://example.org/t/${window.location.search.slice(1)}`;
let el = document.createElement("meta")
el.setAttribute("http-equiv", "refresh");
equiv.setAttribute("content", `0;url=${url}`);
document.head.appendChild(el;

Which adds a <meta> tag to the head section, but it is still not working.