ra-data-postgrest icon indicating copy to clipboard operation
ra-data-postgrest copied to clipboard

No API key found in request

Open matthieup240 opened this issue 2 years ago • 1 comments

I would like to access to the Supabase tables but don't understand how to access with this plugin. Actually, I get this :

const httpClient = (url, options = {}) => {
  options.user = {
      authenticated: true,
      token: process.env.REACT_APP_SUPABASE_ANON
  };
  return fetchUtils.fetchJson(url, options);
};

const dataProvider = postgrestRestProvider(process.env.REACT_APP_SUPABASE_URL, httpClient);
return (
    <Admin dataProvider={dataProvider}>
        <Resource name="posts" list={ListGuesser} />
        <Resource name="authors" list={ListGuesser} />
    </Admin>
)

Si when I try to access to the data, I have this error message : No API key found in request

matthieup240 avatar Oct 18 '22 19:10 matthieup240

This worked for me:

const httpClient = (url, options = {}) => {
  options.user = {
    authenticated: true,
    token: `Bearer ${process.env.REACT_APP_SUPABASE_KEY}`
  };

  options.headers.set('apikey', process.env.REACT_APP_SUPABASE_KEY)

  return fetchUtils.fetchJson(url, options);
};

DictumMortuum avatar Oct 23 '22 13:10 DictumMortuum

@matthieup240 did the last answer resolve your issue? If so, please close this issue.

scheiblr avatar Nov 24 '22 12:11 scheiblr

Problem resolved, thanks

matthieup240 avatar Nov 24 '22 13:11 matthieup240