-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/clean-up
- Loading branch information
Showing
25 changed files
with
880 additions
and
452 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
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,2 +1,23 @@ | ||
import { handlers } from "@/auth"; | ||
export const { GET, POST } = handlers; | ||
import { NextRequest } from "next/server"; | ||
|
||
const reqWithTrustedOrigin = (req: NextRequest): NextRequest => { | ||
if (process.env.AUTH_TRUST_HOST !== "true") return req; | ||
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 const GET = (req: NextRequest) => { | ||
return handlers.GET(reqWithTrustedOrigin(req)); | ||
}; | ||
|
||
export const POST = (req: NextRequest) => { | ||
return handlers.POST(reqWithTrustedOrigin(req)); | ||
}; |
Oops, something went wrong.