Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
•
8715c49
1
Parent(s):
522ddd5
...
Browse files- src/app/api/login/route.ts +18 -12
src/app/api/login/route.ts
CHANGED
@@ -8,10 +8,13 @@ const defaultState = JSON.stringify({
|
|
8 |
})
|
9 |
|
10 |
export async function GET(req: NextRequest) {
|
|
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
console.log("Received GET /api/login:",
|
15 |
console.log(query)
|
16 |
|
17 |
|
@@ -27,16 +30,17 @@ export async function GET(req: NextRequest) {
|
|
27 |
// eg. this can be /account, /, or nothing
|
28 |
const redirectTo = `${state.redirectTo || "/"}`
|
29 |
|
30 |
-
|
31 |
-
const rest = req.url.split("/api/login").pop()
|
32 |
-
|
33 |
-
return NextResponse.redirect(`https://aitube.at${redirectTo}${rest}`)
|
34 |
}
|
35 |
|
36 |
export async function POST(req: NextRequest, res: NextResponse) {
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
console.log("Received POST /api/login:",
|
40 |
console.log(query)
|
41 |
|
42 |
|
@@ -50,10 +54,12 @@ export async function POST(req: NextRequest, res: NextResponse) {
|
|
50 |
|
51 |
// this is the path of the AI Tube page which the user was browser
|
52 |
// eg. this can be /account, /, or nothing
|
53 |
-
const redirectTo = `${state.redirectTo || "/"}`
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
// we are going to pass the whole thing unchanged to the AI Tube frontend
|
56 |
-
const rest = req.url.split("/api/login").pop()
|
57 |
|
58 |
-
return NextResponse.redirect(`https://aitube.at${redirectTo}${
|
59 |
}
|
|
|
8 |
})
|
9 |
|
10 |
export async function GET(req: NextRequest) {
|
11 |
+
// we are going to pass the whole thing unchanged to the AI Tube frontend
|
12 |
+
const params = req.url.split("/api/login").pop() || ""
|
13 |
|
14 |
+
|
15 |
+
const query = querystring.parse(params)
|
16 |
|
17 |
+
console.log("Received GET /api/login:", params)
|
18 |
console.log(query)
|
19 |
|
20 |
|
|
|
30 |
// eg. this can be /account, /, or nothing
|
31 |
const redirectTo = `${state.redirectTo || "/"}`
|
32 |
|
33 |
+
return NextResponse.redirect(`https://aitube.at${redirectTo}${params}`)
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
export async function POST(req: NextRequest, res: NextResponse) {
|
37 |
+
// we are going to pass the whole thing unchanged to the AI Tube frontend
|
38 |
+
const params = req.url.split("/api/login").pop() || ""
|
39 |
+
|
40 |
+
|
41 |
+
const query = querystring.parse(params)
|
42 |
|
43 |
+
console.log("Received POST /api/login:", params)
|
44 |
console.log(query)
|
45 |
|
46 |
|
|
|
54 |
|
55 |
// this is the path of the AI Tube page which the user was browser
|
56 |
// eg. this can be /account, /, or nothing
|
57 |
+
// const redirectTo = `${state.redirectTo || "/"}`
|
58 |
+
|
59 |
+
// for now we have to always return to /account, since this is where
|
60 |
+
// the oauth "finisher" code resides
|
61 |
+
const redirectTo = "/account"
|
62 |
|
|
|
|
|
63 |
|
64 |
+
return NextResponse.redirect(`https://aitube.at${redirectTo}${params}`)
|
65 |
}
|