Skip to content

Commit 4b2e70d

Browse files
committed
ensure primary on provider callback loader
Reference: #665
1 parent e68fb0c commit 4b2e70d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/routes/_auth+/auth.$provider.callback.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '#app/utils/auth.server.ts'
77
import { ProviderNameSchema, providerLabels } from '#app/utils/connections.tsx'
88
import { prisma } from '#app/utils/db.server.ts'
9+
import { ensurePrimary } from '#app/utils/litefs.server.ts'
910
import { combineHeaders } from '#app/utils/misc.tsx'
1011
import {
1112
destroyRedirectToHeader,
@@ -23,6 +24,10 @@ import { prefilledProfileKey, providerIdKey } from './onboarding_.$provider.tsx'
2324
const destroyRedirectTo = { 'set-cookie': destroyRedirectToHeader }
2425

2526
export async function loader({ request, params }: LoaderFunctionArgs) {
27+
// this loader performs mutations, so we need to make sure we're on the
28+
// primary instance to avoid writing to a read-only replica
29+
await ensurePrimary()
30+
2631
const providerName = ProviderNameSchema.parse(params.provider)
2732
const redirectTo = getRedirectCookieValue(request)
2833
const label = providerLabels[providerName]

0 commit comments

Comments
 (0)