Spaces:
Running
Running
fix auth
Browse files- app/api/auth/route.ts +1 -4
- app/auth/page.tsx +1 -8
- middleware.ts +1 -0
app/api/auth/route.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
| 1 |
import { NextRequest, NextResponse } from "next/server";
|
| 2 |
|
| 3 |
export async function GET(req: NextRequest) {
|
| 4 |
-
const host =
|
| 5 |
-
req.headers.get("x-current-host") ??
|
| 6 |
-
req.headers.get("host") ??
|
| 7 |
-
"localhost:3000";
|
| 8 |
|
| 9 |
const redirect_uri =
|
| 10 |
`${host.includes("localhost") ? "http://" : "https://"}` +
|
|
|
|
| 1 |
import { NextRequest, NextResponse } from "next/server";
|
| 2 |
|
| 3 |
export async function GET(req: NextRequest) {
|
| 4 |
+
const host = req.headers.get("host") ?? "localhost:3000";
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
const redirect_uri =
|
| 7 |
`${host.includes("localhost") ? "http://" : "https://"}` +
|
app/auth/page.tsx
CHANGED
|
@@ -1,18 +1,11 @@
|
|
| 1 |
import { redirect } from "next/navigation";
|
| 2 |
import { Metadata } from "next";
|
| 3 |
-
import { headers } from "next/headers";
|
| 4 |
|
| 5 |
import { apiServer } from "@/lib/api";
|
| 6 |
|
| 7 |
async function getLoginUrl() {
|
| 8 |
-
const headersList = await headers();
|
| 9 |
-
const pathname = headersList.get("x-current-host") || "/";
|
| 10 |
try {
|
| 11 |
-
const res = await apiServer.get("/auth"
|
| 12 |
-
headers: {
|
| 13 |
-
"x-current-host": pathname,
|
| 14 |
-
},
|
| 15 |
-
});
|
| 16 |
return res.data;
|
| 17 |
} catch (error) {
|
| 18 |
return error;
|
|
|
|
| 1 |
import { redirect } from "next/navigation";
|
| 2 |
import { Metadata } from "next";
|
|
|
|
| 3 |
|
| 4 |
import { apiServer } from "@/lib/api";
|
| 5 |
|
| 6 |
async function getLoginUrl() {
|
|
|
|
|
|
|
| 7 |
try {
|
| 8 |
+
const res = await apiServer.get("/auth");
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
return res.data;
|
| 10 |
} catch (error) {
|
| 11 |
return error;
|
middleware.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { NextRequest } from "next/server";
|
|
| 3 |
|
| 4 |
export function middleware(request: NextRequest) {
|
| 5 |
const headers = new Headers(request.headers);
|
|
|
|
| 6 |
headers.set("x-current-host", request.nextUrl.host);
|
| 7 |
return NextResponse.next({ headers });
|
| 8 |
}
|
|
|
|
| 3 |
|
| 4 |
export function middleware(request: NextRequest) {
|
| 5 |
const headers = new Headers(request.headers);
|
| 6 |
+
console.log("Middleware Headers:", request.nextUrl);
|
| 7 |
headers.set("x-current-host", request.nextUrl.host);
|
| 8 |
return NextResponse.next({ headers });
|
| 9 |
}
|