Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const https = {
certPath,
keyPath
}
const proxy = mockttp.getLocal({
cors: true,
debug: false,
https,
recordTraffic: false
})
this.proxy = proxy
proxy.addRules(
{
matchers: [
new mockttp.matchers.HostMatcher('amiusing.httptoolkit.tech')
],
handler: new mockttp.handlers.CallbackHandler(request => {
const response: CallbackResponseResult = {
statusCode: 302,
headers: {
location: `https://${config.targetHost}`
}
}
return response
})
},
{
matchers: [
new mockttp.matchers.WildcardMatcher()
],
handler: new mockttp.handlers.PassThroughHandler()
const https = {
certPath,
keyPath
}
const proxy = mockttp.getLocal({
cors: true,
debug: false,
https,
recordTraffic: false
})
this.proxy = proxy;
proxy.addRules(
{
matchers: [
new mockttp.matchers.WildcardMatcher()
],
handler: new mockttp.handlers.PassThroughHandler()
}
)
proxy.on('request', (req: mockttp.CompletedRequest) => {
if (config.targetHosts.includes(req.headers.host)) {
this.requests.set(req.id, req)
} else {
this.unknownHosts.push(normalizeHost(req.headers.host))
}
})
proxy.on('response', (res: mockttp.CompletedResponse) => {
if (this.requests.has(res.id)) {
const req = this.requests.get(res.id) as mockttp.CompletedRequest
matchers: [
new mockttp.matchers.HostMatcher('amiusing.httptoolkit.tech')
],
handler: new mockttp.handlers.CallbackHandler(request => {
const response: CallbackResponseResult = {
statusCode: 302,
headers: {
location: `https://${config.targetHost}`
}
}
return response
})
},
{
matchers: [
new mockttp.matchers.WildcardMatcher()
],
handler: new mockttp.handlers.PassThroughHandler()
}
)
proxy.on('request', (req: mockttp.CompletedRequest) => {
if (req.headers.host === config.targetHost) {
this.requests.set(req.id, req)
}
})
proxy.on('response', (res: mockttp.CompletedResponse) => {
if (this.requests.has(res.id)) {
const req = this.requests.get(res.id) as mockttp.CompletedRequest
const queryString: string = url.parse(req.url).query || ''
const queryParameters = qs.parse(queryString)