Huge number of changes, upgrade to next 15, add loads of pages, auth, add ci, loads of clean up, a db for images etc

This commit is contained in:
2024-10-12 00:35:10 +01:00
parent 7f88af8ee3
commit 81d2cae9c7
42 changed files with 6511 additions and 1440 deletions

View File

@@ -1,7 +1,22 @@
import NextAuth from "next-auth";
import { authConfig } from "@/lib/auth";
import { NextRequest } from "next/server";
import { handlers } from "@/lib/auth";
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const handler = NextAuth(authConfig);
const reqWithTrustedOrigin = (req: NextRequest): NextRequest => {
const proto = req.headers.get('x-forwarded-proto')
const host = req.headers.get('x-forwarded-host')
if (!proto || !host) {
console.warn("Missing x-forwarded-proto or x-forwarded-host headers.")
return req
}
const envOrigin = `${proto}://${host}`
const { href, origin } = req.nextUrl
return new NextRequest(href.replace(origin, envOrigin), req)
}
export { handler as GET, handler as POST };
export const GET = (req: NextRequest) => {
return handlers.GET(reqWithTrustedOrigin(req))
}
export const POST = (req: NextRequest) => {
return handlers.POST(reqWithTrustedOrigin(req))
}