Nextjs Route.push与Express Route不匹配

时间:2019-07-28 09:52:24

标签: express next.js

Nextjs:我的_app中有这个

  handleNormalLogin = (values, formikBag) => {          
        console.log("_app got normal submit log: formik=",formikBag);               
        this.handleClose(); //Login Modal should close
        Router.push({pathname: '/profile'});    
  };

这在我的自定义快递服务器中:

server.get('/profile', (req, res) => {
    console.log("server got profile request!");
    console.log("server req.path= ", req.path);
    console.log("server req.body= ", req.body);
    console.log("server req.query= ", req.query);
    console.log("server req.params= ", req.params);     
    return handle(req, res);
});

server.get('*', (req, res) => {
    console.log("server got random request!");
    console.log("server req.path= ", req.path);
    console.log("server req.body= ", req.body);
    console.log("server req.query= ", req.query);
    console.log("server req.params= ", req.params);     
    return handle(req, res);
});

当handleNormalLogin函数被触发时(在我提交Formik表单之后),“ / profile”路由不匹配: 我收到“服务器收到随机请求!”日志中的条目。

但是,当我转到地址栏-https://localhost:8443/profile-并按Enter调用这样的路线时,它是匹配的: 我收到“服务器收到配置文件请求!”日志中的条目。

为什么?

0 个答案:

没有答案