-
Hi! I'm getting errors with a "read only transaction" message when I try to do a GET request to a defined function that performs inserts. Is there a way to avoid this? I need this to perform:
I tried to set the transaction level to the very first action, but it doesn't allow me to do so. Is there a way to always allow writes regardless of http method? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hey @yevon, GET is enforced to run in a read-only tx, this guarantees idempotency - which is useful for things like retries on the client side.
How are you doing this? I believe it's best to leave that to the db logs. You can even query the logs as a table if you enable csv logging + a FDW.
Can you elaborate on this? |
Beta Was this translation helpful? Give feedback.
-
I was trying to implement a double jwt authentication flow in a SPA application, with short lived tokens and refresh tokens. The problem with that is that for achieving this, I have to register refresh tokens and use browser redirects in this way:
So I cannot perform or repeat the request as a POST because this is a browser behaviour, which repeats redirect request as GET requests because the very first request was a GET. So I have only two options:
|
Beta Was this translation helpful? Give feedback.
-
At the end I implemented this at nginx proxy level, by transforming the GET request to a POST before sending it to PostgREST and got it working. Anyway, there are specific use-cases like this one that would need to specify the transaction level for every method even when it is a bad practice. On the kubernetes side: It seems that you can use mergeable ingresses for applying specific configs to certain paths, like the endpoint that you would want to transform to a POST. You have to define two ingress, one as the master, and then others as child that would overwrite specific configs from the master. All of them with same host but with different paths defined. First ingress:
Second ingress:
|
Beta Was this translation helpful? Give feedback.
At the end I implemented this at nginx proxy level, by transforming the GET request to a POST before sending it to PostgREST and got it working. Anyway, there are specific use-cases like this one that would need to specify the transaction level for every method even when it is a bad practice.
On the kubernetes side:
It seems that you can use mergeable ingresses for applying specific configs to certain paths, like the endpoint that you would want to transform to a POST. You have to define two ingress, one as the master, and then others as child that would overwrite specific configs from the master. All of them with same host but with different paths defined.
First ingress: