-
Notifications
You must be signed in to change notification settings - Fork 467
fix: txn cookie accumulation #2748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
16ae32f
e29c7e0
b6a3296
541a86b
b30ec24
4dd65a7
537de26
27119c4
d1d12f0
e7a44b3
a6af9f6
7867c52
4bc926b
e6193cf
28a8c23
27d2f7f
f97c52a
9564d85
5037282
5e68900
d2a75cf
2bcffd2
591e8c2
f964ab4
ef6b6af
5985220
95baeee
69a4ad6
1a5dfa7
7ef34be
33aae38
169026d
a8484c4
d3dffb8
dda2ea6
47f5732
f34b491
6b38a2e
c5c51f7
5c2bdc0
3bcf846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,7 @@ import { | |
| buildForwardedResponseHeaders, | ||
| transformTargetUrl | ||
| } from "../utils/proxy.js"; | ||
| import { isNonNavigationalRequest } from "../utils/request.js"; | ||
| import { | ||
| ensureDefaultScope, | ||
| getScopeForAudience | ||
|
|
@@ -672,6 +673,9 @@ export class AuthClient { | |
| const method = req.method; | ||
|
|
||
| if (method === "GET" && sanitizedPathname === this.routes.login) { | ||
| if (isNonNavigationalRequest(req)) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Primary fix for the 431: Next.js prefetches to |
||
| return new NextResponse(null, { status: 401 }); | ||
| } | ||
| return this.handleLogin(req); | ||
| } else if (method === "GET" && sanitizedPathname === this.routes.logout) { | ||
| return this.handleLogout(req); | ||
|
|
@@ -947,8 +951,11 @@ export class AuthClient { | |
| // Set response and save transaction | ||
| const res = NextResponse.redirect(authorizationUrl.toString()); | ||
|
|
||
| // Save transaction state | ||
| await this.transactionStore.save(res.cookies, transactionState); | ||
| await this.transactionStore.save( | ||
| res.cookies, | ||
| transactionState, | ||
| req?.cookies | ||
| ); | ||
|
|
||
| return res; | ||
| } | ||
|
|
@@ -1598,7 +1605,6 @@ export class AuthClient { | |
| await this.sessionStore.set(req.cookies, res.cookies, session, true); | ||
| addCacheControlHeadersForSession(res); | ||
|
|
||
| // Clean up the current transaction cookie after successful authentication | ||
| await this.transactionStore.delete(res.cookies, state); | ||
|
|
||
| return res; | ||
|
|
@@ -4177,7 +4183,11 @@ export class AuthClient { | |
| `${connectAccountResponse.connectUri}?ticket=${encodeURIComponent(connectAccountResponse.connectParams.ticket)}` | ||
| ); | ||
|
|
||
| await this.transactionStore.save(res.cookies, transactionState); | ||
| await this.transactionStore.save( | ||
| res.cookies, | ||
| transactionState, | ||
| req?.cookies | ||
| ); | ||
|
|
||
| return [null, res]; | ||
| } | ||
|
|
@@ -5819,7 +5829,11 @@ export class AuthClient { | |
| "Pass the NextResponse cookies (App Router: next/headers cookies; Pages Router: res.cookies)." | ||
| ); | ||
| } | ||
| await this.transactionStore.save(resCookies, magicLinkTransactionState); | ||
| await this.transactionStore.save( | ||
| resCookies, | ||
| magicLinkTransactionState, | ||
| req?.cookies | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.