2
2
import spawn from 'cross-spawn'
3
3
import { existsSync , readFileSync , unlinkSync , writeFileSync } from 'fs'
4
4
import { writeFile } from 'fs-extra'
5
+ import { fetch as undiciFetch } from 'next/dist/compiled/undici'
5
6
import nodeFetch from 'node-fetch'
6
7
import path from 'path'
7
8
import qs from 'querystring'
@@ -110,7 +111,7 @@ async function processChunkedResponse(response) {
110
111
* @param {string | number } appPort
111
112
* @param {string } pathname
112
113
* @param {Record<string, any> | string | undefined } [query]
113
- * @param {import("undici").RequestInit } [opts]
114
+ * @param {import("next/dist/compiled/ undici").RequestInit } [opts]
114
115
* @returns {Promise<string> }
115
116
*/
116
117
export function renderViaHTTP ( appPort , pathname , query , opts ) {
@@ -120,11 +121,11 @@ export function renderViaHTTP(appPort, pathname, query, opts) {
120
121
/**
121
122
* @param {string | number } appPort
122
123
* @param {string } pathname
123
- * @param {Record<string, any> | string | undefined } query
124
- * @param {RequestInit } opts
125
- * @returns {Promise<Response> }
124
+ * @param {Record<string, any> | string | null | undefined } [ query]
125
+ * @param {import('node-fetch'). RequestInit } [ opts]
126
+ * @returns {Promise<Response & {buffer: any} & {headers: Headers} > }
126
127
*/
127
- export async function fetchViaHTTP ( appPort , pathname , query = undefined , opts = undefined , useUndici = false ) {
128
+ export function fetchViaHTTP ( appPort , pathname , query , opts , useUndici = false ) {
128
129
const url = `${ pathname } ${ typeof query === 'string' ? query : query ? `?${ qs . stringify ( query ) } ` : '' } `
129
130
const fetch = useUndici ? undiciFetch : nodeFetch
130
131
const fullUrl = getFullUrl ( appPort , url )
0 commit comments