Skip to content

Commit

Permalink
feat: added path option to redirectToHome helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogrodzki committed Jul 25, 2024
1 parent b4c8264 commit 41b0b8f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# [1.7.0-canary.1](https://github.com/awinogrodzki/next-firebase-auth-edge/compare/v1.6.2...v1.7.0-canary.1) (2024-07-25)


### Features

* introduced `refreshCookiesWithIdToken` function to enable login using Server Actions ([#212](https://github.com/awinogrodzki/next-firebase-auth-edge/issues/212)) ([6cd0b13](https://github.com/awinogrodzki/next-firebase-auth-edge/commit/6cd0b138036ff0f4fcfa91d786fca5255cfa2654))

# [1.7.0-canary.1](https://github.com/awinogrodzki/next-firebase-auth-edge/compare/v1.6.1...v1.7.0-canary.1) (2024-07-16)


Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
setupFiles: ['dotenv/config'],
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
Expand All @@ -8,7 +11,4 @@ module.exports = {
],
'^.+\\.jsx?$': 'babel-jest',
},
setupFiles: ['dotenv/config'],
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
};
13 changes: 11 additions & 2 deletions src/next/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ export interface CreateAuthMiddlewareOptions {
enableMultipleCookies?: boolean;
}

export function redirectToHome(request: NextRequest) {
interface RedirectToHomeOptions {
path: string;
}

export function redirectToHome(
request: NextRequest,
options: RedirectToHomeOptions = {
path: '/'
}
) {
const url = request.nextUrl.clone();
url.pathname = '/';
url.pathname = options.path;
url.search = '';
return NextResponse.redirect(url);
}
Expand Down

0 comments on commit 41b0b8f

Please sign in to comment.