'Redirect to other page (Front-end) - Error code: STATUS_ACCESS_VIOLATION

I have problem with redirecting to other page, and resulting to this error: Error - STATUS_ACCESS_VIOLATION

I'm encountering this when I'm trying to redirect to other page in front-end script:

window.localStorage.setItem('img1', JSON.stringify({img_data}))
window.location.replace("/visitor/login");

Is there problem in setting data in localstorage then redirecting to other page?

I have a route in my server for "/visitor/login":

app.get("/visitor/login", (req, res) => {
    res.render("./Visitor Module/login");
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source