fix(nextjs,backend): Support handshake in iframes - #3555
Conversation
🦋 Changeset detectedLatest commit: 203414f The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
!snapshot |
|
Hey @anagstef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/backend@1.3.0-snapshot.v1ec5424 --save-exact
npm i @clerk/chrome-extension@1.0.18-snapshot.v1ec5424 --save-exact
npm i @clerk/clerk-js@5.7.0-snapshot.v1ec5424 --save-exact
npm i @clerk/elements@0.7.0-snapshot.v1ec5424 --save-exact
npm i @clerk/clerk-expo@1.2.1-snapshot.v1ec5424 --save-exact
npm i @clerk/express@0.0.12-snapshot.v1ec5424 --save-exact
npm i @clerk/fastify@1.0.14-snapshot.v1ec5424 --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/nextjs@5.2.0-snapshot.v1ec5424 --save-exact
npm i @clerk/clerk-react@5.2.4-snapshot.v1ec5424 --save-exact
npm i @clerk/remix@4.1.1-snapshot.v1ec5424 --save-exact
npm i @clerk/clerk-sdk-node@5.0.11-snapshot.v1ec5424 --save-exact
npm i @clerk/shared@2.3.0-snapshot.v1ec5424 --save-exact
npm i @clerk/tanstack-start@0.1.1-snapshot.v1ec5424 --save-exact
npm i @clerk/testing@1.1.7-snapshot.v1ec5424 --save-exact
npm i @clerk/ui@0.1.1-snapshot.v1ec5424 --save-exact |
|
|
||
| // NOTE: we could also check sec-fetch-mode === navigate here, but according to the spec, sec-fetch-dest: document should indicate that the request is the data of a user navigation. | ||
| if (secFetchDest === 'document') { | ||
| if (secFetchDest === 'document' || secFetchDest === 'iframe') { |
There was a problem hiding this comment.
ℹ️ When document requests happend from inside an iframe the Sec-Fetch-Dest value is set to iframe. Fetch/XHR requests do not use this value.
There was a problem hiding this comment.
I propose exporting a SAFE_SEC_FETCH_DESTS array from shared and then consuming it in backend and nextjs, and just checking SAFE_SEC_FETCH_DESTS.includes(secFetchDest)
|
|
||
| // NOTE: we could also check sec-fetch-mode === navigate here, but according to the spec, sec-fetch-dest: document should indicate that the request is the data of a user navigation. | ||
| if (secFetchDest === 'document') { | ||
| if (secFetchDest === 'document' || secFetchDest === 'iframe') { |
There was a problem hiding this comment.
I propose exporting a SAFE_SEC_FETCH_DESTS array from shared and then consuming it in backend and nextjs, and just checking SAFE_SEC_FETCH_DESTS.includes(secFetchDest)
| const isPageRequest = (req: Request): boolean => { | ||
| return ( | ||
| req.headers.get(constants.Headers.SecFetchDest) === 'document' || | ||
| req.headers.get(constants.Headers.SecFetchDest) === 'iframe' || |
There was a problem hiding this comment.
❓ why do we need this as part of this PR? Is this related to the handshake mechanism?
There was a problem hiding this comment.
I believe we need this in order for pages wrapped with protect work properly in the first load via an iframe
There was a problem hiding this comment.
It's not a handshake particular thing, but as @panteliselef said, it will help with protect and iframes.
Co-authored-by: Bryce Kalow <bryce@clerk.dev>
|
!snapshot |
|
!snapshot |
|
Hey @anagstef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@0.0.2-snapshot.v27f3f6b --save-exact
npm i @clerk/backend@1.3.1-snapshot.v27f3f6b --save-exact
npm i @clerk/chrome-extension@1.1.3-snapshot.v27f3f6b --save-exact
npm i @clerk/clerk-js@5.8.1-snapshot.v27f3f6b --save-exact
npm i @clerk/clerk-expo@1.2.6-snapshot.v27f3f6b --save-exact
npm i @clerk/express@0.0.16-snapshot.v27f3f6b --save-exact
npm i @clerk/fastify@1.0.18-snapshot.v27f3f6b --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/nextjs@5.2.3-snapshot.v27f3f6b --save-exact
npm i @clerk/remix@4.2.2-snapshot.v27f3f6b --save-exact
npm i @clerk/clerk-sdk-node@5.0.15-snapshot.v27f3f6b --save-exact
npm i @clerk/tanstack-start@0.1.6-snapshot.v27f3f6b --save-exact
npm i @clerk/testing@1.1.10-snapshot.v27f3f6b --save-exact |
|
!snapshot |
|
Hey @anagstef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@0.0.2-snapshot.v88c02de --save-exact
npm i @clerk/backend@1.3.1-snapshot.v88c02de --save-exact
npm i @clerk/chrome-extension@1.1.3-snapshot.v88c02de --save-exact
npm i @clerk/clerk-js@5.8.1-snapshot.v88c02de --save-exact
npm i @clerk/clerk-expo@1.2.6-snapshot.v88c02de --save-exact
npm i @clerk/express@0.0.16-snapshot.v88c02de --save-exact
npm i @clerk/fastify@1.0.18-snapshot.v88c02de --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/nextjs@5.2.3-snapshot.v88c02de --save-exact
npm i @clerk/remix@4.2.2-snapshot.v88c02de --save-exact
npm i @clerk/clerk-sdk-node@5.0.15-snapshot.v88c02de --save-exact
npm i @clerk/tanstack-start@0.1.6-snapshot.v88c02de --save-exact
npm i @clerk/testing@1.1.10-snapshot.v88c02de --save-exact |
This change makes requests that have the `Sec-Fetch-Dest` value set to `iframe` to be eligible for handshake. Co-authored-by: Bryce Kalow <bryce@clerk.dev>
Description
Adds support for handshake inside iframes.
This PR makes requests that have the
Sec-Fetch-Destvalue set toiframeto be eligible for handshake.Checklist
npm testruns as expected.npm run buildruns as expected.Type of change