uma
uma
CCConvex Community
Created by uma on 3/29/2025 in #support-community
callback, 3rd party authentication, convexAuth
I am running into a problem with Figma Oauth 2.0 callback which returns with ?code=&state= appended to the return URL. Now, the ?code part of it is getting consumed by ConvexAuth. I'd love some help on getting around it. I edited my middleware.ts to do the following:
export default convexAuthNextjsMiddleware((request) => {
const url = new URL(request.url)
console.log('Middleware full URL:', url.href)
// Intercept the Figma callback route to rewrite "code" as "figmaCode"
if (url.pathname.startsWith('/settings/profile/figma-auth-callback') && url.searchParams.has('code')) {
const code = url.searchParams.get('code')!
url.searchParams.delete('code')
url.searchParams.set('figmaCode', code)
// Redirect to the same URL with the renamed query parameter.
return NextResponse.redirect(url)
}
if (!isPublicPage(request as NextRequest) && !isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request as NextRequest, '/auth')
}
})
export default convexAuthNextjsMiddleware((request) => {
const url = new URL(request.url)
console.log('Middleware full URL:', url.href)
// Intercept the Figma callback route to rewrite "code" as "figmaCode"
if (url.pathname.startsWith('/settings/profile/figma-auth-callback') && url.searchParams.has('code')) {
const code = url.searchParams.get('code')!
url.searchParams.delete('code')
url.searchParams.set('figmaCode', code)
// Redirect to the same URL with the renamed query parameter.
return NextResponse.redirect(url)
}
if (!isPublicPage(request as NextRequest) && !isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request as NextRequest, '/auth')
}
})
But that doesn't fix it either. I couldn't use this workaround because I am not using tanstack server: https://github.com/get-convex/convex-auth/issues/145 The work around would be to break out a chunk of code out from ConvexAuthNextjsServerProvider and that is painful. Integration with a third party is common, so what could I be missing? This has to be solved elegantly. A movement on this thread: https://github.com/get-convex/convex-auth/issues/145 as suggested by @ballingt and @sshader would work.
22 replies
CCConvex Community
Created by uma on 9/21/2024 in #support-community
stripe + process.env
For my app, process.env variable for Stripe are being picked up from development area in convex but not project wide default env variables. Does this happen with test keys only? process.env.STRIPE_SECRET_KEY
9 replies