Rewrite responses
Change status, redirects, headers, cookies, CORS, caching, and response bodies.
Response actions run after the upstream server responds and before PostGate sends the response to the client.
Status and redirects
Textapi.example.com/maintenance statusCode://503example.com/old redirect://https://example.com/newexample.com/temporary 307://https://example.com/new
PostGate supports status replacement and 301, 302, 307, and 308 redirects.
Headers, cookies, CORS, and cache
Textapi.example.com resHeaders://x-served-by=postgateapi.example.com resType://application/jsonapi.example.com resCharset://utf-8api.example.com resCors://*downloads.example.com/file attachment://report.pdfassets.example.com cache://max-age=60
resHeaders accepts query-style modifications or a JSON map. Dedicated actions manage response cookies, CORS, content type, charset, attachment filenames, and caching.
Bodies
Textapi.example.com/v1/user resBody://{"ok":true}api.example.com/v1/user resMerge://{"source":"postgate"}api.example.com resPrepend://before-api.example.com resAppend://-afterapi.example.com resReplace://production=local
resBody replaces the entire body, while resMerge merges structured content. Prepend, append, and replace actions modify response content; resWrite and resWriteRaw save the observed body to disk.
Changing a compressed response may require PostGate to decode and re-encode the body. Verify the resulting content type and body in Capture after adding a rewrite.