a
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
|
basePath: process.env.BASE_PATH,
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
images: {
|
images: {
|
||||||
|
|||||||
@@ -1,2 +1,31 @@
|
|||||||
import { handlers } from "@/auth";
|
// import { handlers } from "@/auth";
|
||||||
export const { GET, POST } = handlers;
|
// export const { GET, POST } = handlers;
|
||||||
|
//
|
||||||
|
import { NextRequest } from 'next/server'
|
||||||
|
|
||||||
|
import { handlers } from '@/auth'
|
||||||
|
|
||||||
|
const basePath = process.env.BASE_PATH ?? ''
|
||||||
|
|
||||||
|
function rewriteRequest(request) {
|
||||||
|
let { protocol, host, pathname } = request.nextUrl;
|
||||||
|
|
||||||
|
const headers = request.headers
|
||||||
|
// Host rewrite adopted from next-auth/packages/core/src/lib/utils/env.ts:createActionURL
|
||||||
|
const detectedHost = headers.get("x-forwarded-host") ?? host
|
||||||
|
const detectedProtocol = headers.get("x-forwarded-proto") ?? protocol
|
||||||
|
const _protocol = detectedProtocol.endsWith(":")
|
||||||
|
? detectedProtocol
|
||||||
|
: detectedProtocol + ":";
|
||||||
|
const url = new URL(`${_protocol}//${detectedHost}${basePath}${pathname}${request.nextUrl.search}`)
|
||||||
|
|
||||||
|
return new NextRequest(url, request)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(request, props) {
|
||||||
|
return await handlers.GET(rewriteRequest(request))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(request, props) {
|
||||||
|
return await handlers.POST(rewriteRequest(request))
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ export const providerMap = providers.map((provider) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const basePath = process.env.BASE_PATH ?? ''
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
basePath: `${basePath}/api/auth`,
|
||||||
providers,
|
providers,
|
||||||
pages: {
|
pages: {
|
||||||
signIn: "/signin",
|
signIn: "/signin",
|
||||||
|
|||||||
Reference in New Issue
Block a user