-
Notifications
You must be signed in to change notification settings - Fork 460
fix(nextjs,backend): Support handshake in iframes #3555
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 all commits
1ec5424
a46259f
e157ad8
ba8e13e
148bf15
c96e9ea
e04603b
27f3f6b
88c02de
a73c9b9
203414f
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@clerk/backend': patch | ||
| '@clerk/nextjs': patch | ||
| --- | ||
|
|
||
| Fixes a bug where Clerk's Handshake mechanism would not run when an application is rendered in an iframe. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,7 @@ const isServerActionRequest = (req: Request) => { | |
| const isPageRequest = (req: Request): boolean => { | ||
| return ( | ||
| req.headers.get(constants.Headers.SecFetchDest) === 'document' || | ||
| req.headers.get(constants.Headers.SecFetchDest) === 'iframe' || | ||
|
Contributor
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. ❓ why do we need this as part of this PR? Is this related to the handshake mechanism?
Contributor
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. I believe we need this in order for pages wrapped with protect work properly in the first load via an iframe
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. It's not a handshake particular thing, but as @panteliselef said, it will help with |
||
| req.headers.get(constants.Headers.Accept)?.includes('text/html') || | ||
| isAppRouterInternalNavigation(req) || | ||
| isPagesRouterInternalNavigation(req) | ||
|
|
||
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.
ℹ️ When
documentrequests happend from inside an iframe theSec-Fetch-Destvalue is set toiframe. Fetch/XHR requests do not use this value.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.
I propose exporting a
SAFE_SEC_FETCH_DESTSarray from shared and then consuming it in backend and nextjs, and just checkingSAFE_SEC_FETCH_DESTS.includes(secFetchDest)