Skip to content

Commit

Permalink
debug: authCallbackにデバックコードを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
testusuke committed Oct 6, 2024
1 parent 2c65302 commit 899291c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/api/auth/callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import {NextRequest} from "next/server"

export async function POST(request: NextRequest) {
console.log("Auth Endpoint.")

// form data
const form = await request.formData()
// get state and code
const code = form.get('code')

console.log("Code is ", code)

// pass code to the backend
const loginEndpoint = process.env.NEXT_PUBLIC_API_URL + '/login'

console.log("Login Endpoint ", loginEndpoint)

// redirect uri
const redirectUri = process.env.NEXT_PUBLIC_OIDC_REDIRECT_URL

console.log("Redirect URL ", redirectUri)

console.log("Post Backend API")

// post code to the backend using fetch
const response = await fetch(loginEndpoint, {
method: 'POST',
Expand All @@ -24,9 +34,13 @@ export async function POST(request: NextRequest) {
}),
})

console.log("Fetch done")

// get cookie from response
const cookie = response.headers.get('set-cookie')

console.log("cookie", cookie)

if (cookie) {
// redirect to root page
return new Response(null, {
Expand Down

0 comments on commit 899291c

Please sign in to comment.