Troubles with 'routers.js'

Hi.
I try to use the module wix-router but I encountering some problems:

  1. I had created a ‘routers.js’ file in the backend section but I can not delete it (right parameter icon’s do not appear).
  2. I use your examples but it does’t work when I send a query from my code, I get an error 404 not found.
    Regards.
1 Like

Hay bokdany,

Can you share the code you are using? It is a bit hard to understand a 404 case without more details.

Hi Yoav,

May be I don’t understand the essence of the wix-router module, because I maked a lot of trying without results.

I have this page => “http://www.mySite.com/page1” and I would like to redirect the user on this page => “http://www.mySite.com/page2” so I use the code following in the ‘routers.js’(backend section):

import {ok} from ‘wix-router’;
export function page1 _Router(request) {
return ok(" page2 ");
}

or,

import {redirect} from ‘wix-router’;
export function page1 _Router(request) {
return redirect(" http://www.mySite.com/page2 ");
}

I publish the site and I go to the page1 of the site, but nothing happens. Could you tell me what is wrong?

Hi,

Note that it is not enough to write down the code
There is a setup process to perform prior.
You can see a step by step guide here

up