mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-21 18:22:00 +00:00
final fix
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m36s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m36s
This commit is contained in:
parent
b9cfc55751
commit
d14b0b35a3
@ -2,4 +2,6 @@ FROM oven/bun:1.1.42-debian
|
|||||||
|
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
RUN apt update && apt install openssl -y
|
||||||
|
|
||||||
CMD bunx prisma studio
|
CMD bunx prisma studio
|
||||||
|
@ -3,21 +3,34 @@ import type { Session } from "better-auth/types";
|
|||||||
import { type NextRequest, NextResponse } from "next/server";
|
import { type NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
export default async function authMiddleware(request: NextRequest) {
|
export default async function authMiddleware(request: NextRequest) {
|
||||||
const { data: session } = await betterFetch<Session>(
|
const protocol = request.headers.get("x-forwarded-proto") || "http";
|
||||||
"/api/auth/get-session",
|
const host = request.headers.get("host") || "localhost:3000";
|
||||||
{
|
|
||||||
baseURL: request.nextUrl.origin,
|
|
||||||
headers: {
|
|
||||||
//get the cookie from the request
|
|
||||||
cookie: request.headers.get("cookie") || "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!session) {
|
console.log(protocol)
|
||||||
|
console.log(host)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data: session } = await betterFetch<Session>(
|
||||||
|
"http://localhost:3000/api/auth/get-session",
|
||||||
|
{
|
||||||
|
baseURL: `${protocol}://${host}`,
|
||||||
|
headers: {
|
||||||
|
//get the cookie from the request
|
||||||
|
cookie: request.headers.get("cookie") || "",
|
||||||
|
host: host
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!session) {
|
||||||
|
return NextResponse.redirect(new URL("/login", request.url));
|
||||||
|
}
|
||||||
|
return NextResponse.next();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Middlewaree", error);
|
||||||
return NextResponse.redirect(new URL("/login", request.url));
|
return NextResponse.redirect(new URL("/login", request.url));
|
||||||
}
|
}
|
||||||
return NextResponse.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user