-
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.
Merge pull request #10 from podcodar/marco/handle-redirects
Improve authentication workflow
- Loading branch information
Showing
8 changed files
with
57 additions
and
42 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
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 was deleted.
Oops, something went wrong.
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,15 +1,16 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { ORIGIN_URL_KEY } from "@/shared/settings"; | ||
|
||
export function middleware(request: NextRequest) { | ||
// add origin path to redirect when not session available | ||
const headers = new Headers(request.headers); | ||
headers.set("x-url", request.nextUrl.pathname); | ||
headers.set(ORIGIN_URL_KEY, request.nextUrl.pathname); | ||
|
||
return NextResponse.next({ | ||
request: { headers } | ||
}); | ||
}; | ||
|
||
export const config = { | ||
matcher: ["/admin/:path*"] | ||
matcher: ["/app/:path*", "/admin/:path*"] | ||
}; |
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,10 +1,21 @@ | ||
import { headers } from "next/headers"; | ||
import { NextAuthOptions } from "next-auth"; | ||
import GithubProvider from "next-auth/providers/github"; | ||
import { githubCredentials } from "./settings"; | ||
import { NO_SESSION_REDIRECT, ORIGIN_URL_KEY, githubCredentials } from "./settings"; | ||
|
||
export const authOptions: NextAuthOptions = { | ||
providers: [GithubProvider(githubCredentials)], | ||
pages: { | ||
signIn: "/login" | ||
} | ||
}; | ||
|
||
export function getOriginPath() { | ||
const headerObj = headers(); | ||
const origin = headerObj.get(ORIGIN_URL_KEY) ?? ""; | ||
return origin; | ||
} | ||
|
||
export function makeRedirectURL(origin: string) { | ||
return `${NO_SESSION_REDIRECT}${origin}`; | ||
} |
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
1ee18d3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
app – ./
app-podcodar.vercel.app
app.podcodar.com
app-zeta-two.vercel.app
app-git-main-podcodar.vercel.app