Error: Option apiKey is required in Remix loader
Hello, I've been trying to query from Xata in a Remix loader, and am getting this error.
I'm aware that queries should only be run on the server, but from what I understand, Remix loaders only run on the server, so I don't think that's the issue.
I found a workaround, which is to manually add
apiKey
and branch
to the XataClient
instance that is generated by the CLI.
But that means I have to manually do that every time I update the schema. Is there something obvious I'm missing?
Thanks!Securely querying your database with Xata
Connect to a Xata database and fetch data from client-side apps without exposing security keys.
2 Replies
Hi there, thanks for reaching out, let me take a look and see if there's a better solution.
So, I was able to query in a remix loader without passing my api key and after following this tutorial . You could try following this guide from scratch and see if you can get it to work without adding the apiKey etc.
I'd also recommend running the
xata status
and xata auth status
commands in your project directory to check if the api key can be loaded.ok, thanks for the reply - I was following that tutorial, but something must have gotten mixed up with the API keys