"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.wrapRequest = wrapRequest;
var _requestMeta = require("../../../../request-meta");
var _request = require("../../../../web/spec-extension/request");
var _utils = require("../../../../web/utils");
function wrapRequest(req) {
    const { originalRequest  } = req;
    const url = (0, _requestMeta).getRequestMeta(originalRequest, "__NEXT_INIT_URL");
    if (!url) throw new Error("Invariant: missing url on request");
    // HEAD and GET requests can not have a body.
    const body = req.method !== "GET" && req.method !== "HEAD" && req.body ? req.body : null;
    return new _request.NextRequest(url, {
        body,
        // @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457
        duplex: "half",
        method: req.method,
        headers: (0, _utils).fromNodeHeaders(req.headers)
    });
}

//# sourceMappingURL=wrap-request.js.map