MCPcopy
hub / github.com/simstudioai/sim / buildProxyUrl

Function buildProxyUrl

apps/sim/tools/http/request.test.ts:527–545  ·  view source on GitHub ↗
(params: any)

Source from the content-addressed store, hash-verified

525 process.env.VITEST = undefined
526
527 const buildProxyUrl = (params: any) => {
528 const baseUrl = 'https://external-api.com/endpoint'
529 let proxyUrl = `/api/proxy?url=${encodeURIComponent(baseUrl)}`
530
531 if (params.method) {
532 proxyUrl += `&method=${encodeURIComponent(params.method)}`
533 }
534
535 if (
536 params.body &&
537 ['POST', 'PUT', 'PATCH'].includes(params.method?.toUpperCase() || '')
538 ) {
539 const bodyStr =
540 typeof params.body === 'string' ? params.body : JSON.stringify(params.body)
541 proxyUrl += `&body=${encodeURIComponent(bodyStr)}`
542 }
543
544 return proxyUrl
545 }
546
547 const getParams = {
548 url: 'https://external-api.com/endpoint',

Callers 1

request.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected