dan—1106
Explore posts from serversBABetter Auth
•Created by dan—1106 on 4/9/2025 in #help
User avatars/profile pics for Microsoft Entra social sign in
Hello, I am trying to implement social sign in with Microsoft Entra.
In the Entra dashboard my App Registration has selected User.Read and User.ReadBasic.All (the latter gives "Allows the app to read a basic set of profile properties of other users in your organization on your behalf. Includes display name, first and last name, email address and photo.")
My better auth config lists the User.ReadBasic.All scope:
But the record inserted into the DB by Better Auth doesn't have a profile photo.
I'd really appreciate some help figuring this out? Thank you!
14 replies
PPrisma
•Created by dan—1106 on 2/24/2025 in #help-and-questions
Easiest way to investigate a slow Prisma D1 query?
I have an instance of Prisma that I'm using to run a query.
The code consistently takes 200 - 250ms to run. On the D1 dashboard the query time is 0.4ms.
I would like to understand where that extra time is coming from (serializing the result, waiting on the d1 api, etc)
What's the easiest way to do that with this one query?
5 replies
BABetter Auth
•Created by dan—1106 on 2/19/2025 in #help
Set the correct Typescript type when using plugins
I'm using the admin and organization plugins from
better-auth/plugins
.
I'm explicitly typing by betterAuth
instance as ReturnType<typeof betterAuth>;
, but when I try to access one of the API provided functions, e.g. betterAuth.api.listUsers, TS warns me it doesn't exist.
What is the correct typing for my betterAuth
instance?39 replies
BABetter Auth
•Created by dan—1106 on 2/18/2025 in #help
Generate Oauth/Social sign in links server side
I'm just getting started with better-auth and have what might be a basic question.
I want to generate a sign in link on my server. What is the correct API method to do that?
e.g. I want a URL for a "sign in to google" button that I can include in my server side template (either in a form as the form action, or as a link URL)
5 replies
CDCloudflare Developers
•Created by dan—1106 on 2/17/2025 in #workers-help
Accessing D1 outside of a request in an Astro app
I'm using astro-auth [1] in an on-demand rendered app, using adapter-cloudflare [2] to deploy to Cloudflare workers.
My auth.config.ts file exists outside of a request, so I can't access my D1 database (context.locals.runtime.env.DB)
Is it possible to access the Cloudflare runtime outside of a request? If not, any tips on how to initialize astro-auth in middleware?
[1] https://github.com/nowaythatworked/auth-astro
[2] https://docs.astro.build/en/guides/integrations-guide/cloudflare/
2 replies
CDCloudflare Developers
•Created by dan—1106 on 2/11/2025 in #workers-help
Is it possible to dynamically use D1 databases
The documentation on D1 limits [1] says "Each D1 database can store up to 10 GB of data, and you can create up to thousands of separate D1 databases. This allows you to split a single monolithic database into multiple, smaller databases, thereby isolating application data by user, customer, or tenant."
Is it possible to dynamically create and connect to D1 databases from a worker. E.g. A customer signs up, I create a database for them, I then read/write to/from that database.
A post on the Cloudflare forums [2] around a year ago said "The team is working on dynamic binding, but not available yet.". Is it possible now?
[1] https://developers.cloudflare.com/d1/platform/limits/
[2] https://community.cloudflare.com/t/using-d1-instances-dynamically/661841
5 replies
Honox + Vite + Prisma
When I try to use Prisma client libraries,
I get errors in my dev server:
When I try to deploy, I get errors:
This is my vite.config.ts file:
These are my npm scripts:
I can make the dev server work by setting ssr.external to a list of the prisma libraries, but that doesn't solve the prod deployment.
What's the right vite config to get Prisma working well with Cloudflare Workers + Honox?
1 replies
PPrisma
•Created by dan—1106 on 2/7/2025 in #help-and-questions
Vite + D1 + Cloudflare Workers + Prisma
I've used Prisma + D1 + Cloudflare workers before and it's been a great experience.
I'm not trying to use the same tack with Vite + Honox (https://github.com/honojs/honox/tree/main) in the mix.
My vite config uses two plugins:
Using prisma modules causes errors:
e.g.
causes this error
Are there any tricks to a vite config that will work with Prisma client libraries, but also allow the cloudflare worker build plugin to work (to rollup into a single output file with no external dependencies)
6 replies
CDCloudflare Developers
•Created by dan—1106 on 1/31/2025 in #workers-help
SvelteKit (Vite) + D1 + Prisma Local development
I have a SvelteKit app that I'm developing with a D1 database accessed through Prisma.
I'm trying to run the Vite development server locally and have it connect to D1 locally.
My app works when deployed to workers (with experimental assets enabled), and can read/write from the D1 database via Prisma.
The code to initialize my database connection is:
Running locally, I typically run
vite dev --host
Is there a way to get vite dev
running so that it can access a local D1 Instance provided by Wrangler?
If not, is there a way to get that running so that my local dev environment could write to a real/hosted D1 instance that I specify?
Let me know if there's other info that could be helpful2 replies