我能够在成功登录后成功将用户重定向到相关仪表板页面。但是,在这种情况下,URI 被严重污染了'somedomain.com/v1/internal/salesman/dashboard?name=SomeName&email=someemail&uid=somenumber'
。我希望做一些事情,redirect(<DashBoard someProps={someProps}/>
而不是污染 URI。是否有可能在 NextJS 中实现我想要的?
const onSubmit = async (e) => {
e.preventDefault();
const server_path = process.env.SERVER_ADDRESS;
try{
const res = await fetch(`${server_path}api/v1/internal/salesman/signin`, {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({email: email.val, password: password.val})
});
if(await res.status === 200){
const data = await res.json();
router.push({pathname: '/internal/salesman/dashboard', query: {name: data.name, email: data.email, uid: data.uid}});
}
} catch(error){
console.log(error);
}
}