MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / redirect

Function redirect

web/src/app/api/auth/[...nextauth]/auth-options.ts:102–131  ·  view source on GitHub ↗
({ url, baseUrl })

Source from the content-addressed store, hash-verified

100 return session
101 },
102 async redirect({ url, baseUrl }) {
103 const potentialRedirectUrl = new URL(url, baseUrl)
104 const authCode = potentialRedirectUrl.searchParams.get('auth_code')
105
106 if (authCode) {
107 const onboardUrl = new URL(`${baseUrl}/onboard`)
108 potentialRedirectUrl.searchParams.forEach((value, key) => {
109 onboardUrl.searchParams.set(key, value)
110 })
111 logger.debug(
112 { url, authCode, redirectTarget: onboardUrl.toString() },
113 'Redirecting CLI flow to /onboard',
114 )
115 return onboardUrl.toString()
116 }
117
118 if (url.startsWith('/') || potentialRedirectUrl.origin === baseUrl) {
119 logger.debug(
120 { url, redirectTarget: potentialRedirectUrl.toString() },
121 'Redirecting web flow to callbackUrl',
122 )
123 return potentialRedirectUrl.toString()
124 }
125
126 logger.debug(
127 { url, baseUrl, redirectTarget: baseUrl },
128 'Callback URL is external or invalid, redirecting to baseUrl',
129 )
130 return baseUrl
131 },
132 },
133 events: {
134 createUser: async ({ user }) => {

Callers 6

AgentRedirectPageFunction · 0.50
OnboardFunction · 0.50
CategoryPageFunction · 0.50
SponseePageFunction · 0.50
ConfigPageFunction · 0.50
AdminLayoutFunction · 0.50

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected