[英]How can you just get server side rendering result on nextjs?
In a api route of my nextjs server, I want to request the server itself for a page where it will perform validation and return the result(whether it's validate or not), and I'll do next step depending on the result.在我的 nextjs 服务器的api 路由中,我想向服务器本身请求一个页面,它将执行验证并返回结果(无论是否验证),我将根据结果执行下一步。
I need this flow because I want to use same validation codes on both client side and server side, and the codes depend on hooks(like redux selector).我需要这个流程,因为我想在客户端和服务器端使用相同的验证代码,并且代码取决于钩子(如 redux 选择器)。
Is it possible?可能吗? Or is there any work around to meet what I intend to do?
或者有什么办法可以满足我打算做的事情吗? I hope there is at least a way to redirect in component during server side rendering as workaround.
我希望至少有一种方法可以在服务器端渲染期间重定向组件作为解决方法。
If it's possible, would there be a way for a nextjs to return just a simple text message as the page result?如果可能的话,nextjs 是否有办法只返回一条简单的文本消息作为页面结果? So I can easily see if validation has gone ok.
所以我可以很容易地看到验证是否正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.