X
Xata15mo ago
teri

Error in Next.js app with inserting a record

Why is the error persisting?
Uncaught Error: You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error.
Uncaught Error: You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error.
7 Replies
Enemykite
Enemykite15mo ago
You need to run your code in app/page.ts or app/api/route.ts rather than something like component/component.ts. Basically the code needs to be run on the server, not the client
Enemykite
Enemykite15mo ago
If you check the Next JS starter, it will show you the proper way to make these calls https://xata.io/docs/getting-started/nextjs
Get started with Next.js and Xata
Get started with Next.js and Xata
teri
teriOP15mo ago
Let me try your suggestion @Enemykite
Enemykite
Enemykite15mo ago
The sample gallery app is also a good place to check. You'll see that xata is only used server side, in the app folder (which are server side), not the components (which are client side). https://github.com/xataio/sample-nextjs-chakra-gallery-app
GitHub
GitHub - xataio/sample-nextjs-chakra-gallery-app: Gallery applicati...
Gallery application built with Xata, Next.js and Chakra UI - GitHub - xataio/sample-nextjs-chakra-gallery-app: Gallery application built with Xata, Next.js and Chakra UI
teri
teriOP15mo ago
I used Vite for Next.js boilerplate. I need help
Enemykite
Enemykite15mo ago
hey @teri. what do you need help with. i don't have access to your code so you'll need to give me some details about where you're running into trouble
teri
teriOP15mo ago
I have fixed it from the previous error message I had in this channel.
Want results from more Discord servers?
Add your server