Query parameter for POST request #3557
-
I am using PostgREST to do an HTTP integration with Chirpstack. The way Chirpstack works is it does a POST requests with the body being the json data of the event, it also appends event=eventstatus to the URL. As far as I can understand, PostgREST tries to use the event query parameter as a filter, which then leads to the endpoint returning 400 (Bad request). I was wondering if there was a way to fix this. I also tried to add the event parameter to my PL/pgSQL function as a parameter, but I think it's trying to fetch it from the body instead of the URL. Also, I would not care if the event query parameter would simply be ignored. Anything would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Currently there's no way to configure which query parameters to ignore directly in PostgREST. You'll need to use a reverse proxy like Nginx to handle those query parameters. See the docs for an example on how to set Nginx for PostgREST. In that example you can handle the query parameter at the beginning of the location /api/ {
# This matches any query string that ends in `event=<any_value>`
# And replaces it with what was before that query param
if ($args ~* "(.*)(event=.*)") {
set $args "$1";
}
# The rest of the configuration ...
} This the simplest attempt, it can be better refined to your needs. For example, since it's appended, I'm assuming that the query param goes at the end. Also, if the |
Beta Was this translation helpful? Give feedback.
Currently there's no way to configure which query parameters to ignore directly in PostgREST. You'll need to use a reverse proxy like Nginx to handle those query parameters. See the docs for an example on how to set Nginx for PostgREST.
In that example you can handle the query parameter at the beginning of the
location
definition, something like this:This the simplest attempt, it can be better refined to your needs. For example, since it's appended…