svrjs-nextjs-website/pages/docs/api/proxy-api.md

1.3 KiB

title
Proxy API (legacy)

Proxy API (legacy)

Added in SVR.JS 3.4.21, 3.7.0

This API is exposed only to mods. It is invoked, when client connects with the server using CONNECT method.

This API was present from SVR.JS 3.0.0, however SVR.JS version older than 3.4.21 or 3.7.0 had a bug, which involves calling non-proxy callback, instead of proxy one. A workaround involves calling proxy callback over non-proxy one, when request uses CONNECT method (insert at beginning of non-proxy callback):

if (!res.writeHead) {
	Mod.prototype.proxyCallback(
		req,
		res,
		serverconsole,
		responseEnd,
		href,
		ext
	)();
	return;
}

req

Added in SVR.JS 3.4.21, 3.7.0

req object is the same, as req object in Node.JS

socket

Added in SVR.JS 3.4.21, 3.7.0

socket object is the same, as socket object in Node.JS

head

Added in SVR.JS 3.4.21, 3.7.0

head object is the same, as head object in Node.JS

configJSON

Added in SVR.JS 3.4.21, 3.7.0

See configJSON in non-proxy API

serverconsole

Added in SVR.JS 3.4.21, 3.7.0

See serverconsole in non-proxy API

elseCallback()

Added in SVR.JS 3.4.21, 3.7.0

See elseCallback in non-proxy API