Error occurred when using Vite

We know Vite is a blazing fast build tool, but when I host my frontend in localhost using Vite, and redirect my plugin UI to localhost changing window.location.href, the following error occurred:


There’s no error when I open the same page in the browser.

Any idea why this happened and how to fix this?

Turns out, deleting the node_modules and reinstalling them fixed the problem.