But I want to redirect to a URL from the backend. Is there any way to do so - maybe using some npm package or basic javascript?
I know that we can return a response from the backend to the frontend and then use wix-location API but I want to learn a new way to do so since that could save one extra step
I don’t think that is possible (I maybe mistaken).
The issue is that what runs in the browser and what runs in the backend (server) are 2 different locations.
When you redirect to a new page, it is your browser that performs that task. You browser is responsible for displaying pages and going to new websites and loading their pages.
The stuff that runs in the backend, runs on a server and not on your desktop/mobile device etc. Since the backend is not running in a brower, it would not make sense for a redirect to work in the backend.
The backend server, just runs code in a javascript (or similar type) file. It has no sense of any other web address location. It can use folders that are local to it to fetch/save information to. The code running in the backend can also reach out to another external server on the web through an external API call. It can interact with another external server to get data/send data etc.