再会,
我很惊讶我找不到任何关于包的功能getRequestHandler和render功能的信息next。
我正在尝试设置自定义服务器,并且想知道该render功能实际上在做什么或者为什么使用它?getRequestHandler清楚地呈现应用程序,那么为什么我要使用渲染来手动传递路径?另外,分别传入路径名和查询有什么意义?
我显然对这两个用例感到困惑 - 在哪种情况下我会使用其中一个?
谢谢大家的帮助。
阿纳尼
请参阅https://nextjs.org/docs/advanced-features/custom-server
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare().then(() => {
createServer((req, res) => {
// Be sure to pass `true` as the second argument to `url.parse`.
// This tells it to parse the query portion of the URL.
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
if …Run Code Online (Sandbox Code Playgroud)