in src/msha/handlers/function.handler.ts [88:123]
export function handleFunctionRequest(req: http.IncomingMessage, res: http.ServerResponse) {
let cliApiUri = SWA_CLI_API_URI();
const { protocol, hostname, port } = parseUrl(cliApiUri);
const target = hostname === "localhost" ? `${protocol}//127.0.0.1:${port}` : cliApiUri;
if (HAS_API) {
logger.silly(`function request detected. Proxying to Azure Functions emulator`);
logger.silly(` - target: ${chalk.yellow(target)}`);
} else {
logger.log(`***************************************************************************`);
logger.log(`** Functions request detected but no endpoint configuration was found. **`);
logger.log(`** Please use the --api-location option to configure a function endpoint.**`);
logger.log(`***************************************************************************`);
}
proxyApi.web(
req,
res,
{
target,
},
onConnectionLost(req, res, target, "↳"),
);
proxyApi.once("proxyReq", (proxyReq: http.ClientRequest) => {
injectHeaders(proxyReq, target);
injectClientPrincipalCookies(proxyReq);
});
proxyApi.once("proxyRes", (proxyRes: http.IncomingMessage) => {
logger.silly(`getting response from remote host`);
logRequest(req, "", proxyRes.statusCode);
});
logRequest(req, target);
}