Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc error #15

Open
rehacktive opened this issue May 14, 2023 · 5 comments
Open

rpc error #15

rehacktive opened this issue May 14, 2023 · 5 comments

Comments

@rehacktive
Copy link

Hello,
I've tried to use the client rpc call with something like:

client.DB.Rpc("search",....)

but I get the error:

Post "/rpc/public/search": unsupported protocol scheme ""

I think there's an issue with the baseURL in the client maybe? can you help? thanks

@JeffWelder
Copy link

I'm getting the same issue here.

@whoiscarlo
Copy link
Contributor

Any updates on this?

@whoiscarlo
Copy link
Contributor

Alright created a fix for this issue PR.

The problem was that the Rpc() method on line 64 in the file client.go found in postgrest-go/pkg/client.go is failing because the http.NewRequest function isn't given the full REST_URL to the supabase project. Currently it's getting /rpc/[function_name], when it should be https://$SUPABASE_URL/rest/v1/rpc/[function_name].

As a temporary solution until the PR is accepted you can overwrite the file $HOME/go/pkg/mod/github.com/nedpals/postgrest-go@[latest_version]/pkg/client.go and replace line 64 with:

url := c.Transport.baseURL.String() + "/rpc/" + f
req, err := http.NewRequest("POST", url, bytes.NewBuffer(b))

Cheers!

@whoiscarlo
Copy link
Contributor

Updated the PR again because I ran into http.bodyEOFSignal errors when the Postgres function is more complex.

Also, I rewrote the Rpc method to work similar to the From method, this way users can determined what data type they get back, if they are expecting something.

@whoiscarlo
Copy link
Contributor

The PR has been accepted but the new tag hasn't been released so it won't work until then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants