PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
22.65k stars 1k forks source link

Any experience proxyng rpc with node http-proxy-middleware? #3565

Closed pvilas closed 3 weeks ago

pvilas commented 3 weeks ago

In node (express)+http-proxy-middleware

I'm proxying well all the calls to /api to the postgrest server and all works well selecting like http://localhost:8081/api/importacion?limit=10&offset=0, but when I call an rpc it seems that the proxy is unable to get the response. The rpc works well if I call directly http://postgrest:3000/rpc/crea_factura_emitida but hangs if I call 'http://localhost:8081/api/rpc/crea_factura_emitida`

Do I need additional header configuration to make an rpc?

const { createProxyMiddleware } = require('http-proxy-middleware');
app.use('/api', createProxyMiddleware({
  target: "http://postgrest:3000/", 
  changeOrigin: true,
  })  

Headers

Request URL: http://localhost:8081/api/rpc/crea_factura_emitida
Referrer Policy: strict-origin-when-cross-origin
Accept: */*
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.9,es-ES;q=0.8,es;q=0.7
Authorization: Bearer eyJhbGc...
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 2054
Content-Type: text/plain;charset=UTF-8
Cookie: token=eyJhbGci...
Host: localhost:8081
Origin: http://localhost:8081
Pragma: no-cache
Prefer: params=single-object
Referer: http://localhost:8081/app
Sec-Ch-Ua: "Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36