I place this code in a page to redirect
import {redirect} from ‘wix-router’;
export function myRouter_Router(request) {
return redirect(“external_url”, “301”);
}
but error shows on the console: Cannot find module ‘wix-router’ in ‘public/pages/p9pk3.js’
and no redirect.
Does anyone have same experience? How to resolve this?
Please help, thanks!
@precioush2o wix-router is a backend function not a public one. If you are really building a router capability then you need to create a router page in the editor. This will set up the router.js file in backend for you to work with:
https://support.wix.com/en/article/corvid-creating-a-router
If what you are really trying to do is route to another page or site from the browser then you should use wix-location which has a to() function for that purpose:
https://www.wix.com/corvid/reference/wix-location.html#to
Thank @Steven Cropper very much!
The first time I think the wix-router can help to redirect (and able returns 301 status so that reserves SEO) a request (to a WIX page URL) to an non-WIX site page URL. Unfortunately It does not.
The wix-location does redirect, unfortunately it is a client request then does not reserve SEO.
All this means WIX does not support reserve SEO data, the site owner will lose their WIX site SEO data when building a new non-WIX website. It is terrible business.
I am having the exact same issue, were you able to find a solution?
P lease observe the community guidelines and refrain from multiple posts on the same topic or question.
Your question was answered in your other post.
This is an old thread and is being closed.