-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nextauthjs/next-auth#10928 (comment) とかに対処法がある
- Loading branch information
Showing
1 changed file
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
import { handlers } from "@/auth" // Referring to the auth.ts we just created | ||
export const { GET, POST } = handlers | ||
export const runtime = "edge" // optional | ||
import { NextRequest } from 'next/server'; | ||
//export const { GET, POST } = handlers | ||
//export const runtime = "edge" // optional | ||
|
||
const basePath = '/sekirei-todo'; | ||
|
||
const toForwardedRequest = (req: NextRequest): NextRequest => { | ||
const forwardedHost = req.headers.get('x-forwarded-host'); | ||
const forwardedProto = req.headers.get('x-forwarded-proto'); | ||
if (forwardedHost && forwardedProto) { | ||
const forwardedUrl = | ||
`${forwardedProto}://${forwardedHost}${basePath}${req.nextUrl.pathname}?${req.nextUrl.searchParams.toString()}`; | ||
const newReq = new NextRequest(forwardedUrl, { | ||
headers: req.headers, | ||
method: req.method, | ||
body: req.body, | ||
}); | ||
return newReq; | ||
} else { | ||
return req; | ||
} | ||
} | ||
|
||
export const GET: (req: NextRequest) => Promise<Response> = | ||
(req) => handlers.GET(toForwardedRequest(req)); | ||
|
||
export const POST: (req: NextRequest) => Promise<Response> = | ||
(req) => handlers.POST(toForwardedRequest(req)); |