-
Notifications
You must be signed in to change notification settings - Fork 8
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
Use separate jwt's for invoking preview and storing preview state #2691
Conversation
0dbf222
to
e44e6f3
Compare
} | ||
|
||
const data = await verifySitePreviewJwt(jwt); | ||
if (!data) { | ||
return NextResponse.json({ error: "JWT-validation failed." }); |
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.
Should this return a 200 status code?
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.
Now 400: e44e6f3
@@ -11,10 +11,13 @@ async function legacyPagesRouterSitePreviewApiHandler( | |||
const jwt = params.jwt; | |||
|
|||
if (typeof jwt !== "string") { | |||
throw new Error("Missing jwt parameter"); | |||
return res.end("JWT-Parameter is missing."); |
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.
This should probably be 400 bad request
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.
HTTP 401 Unauthorized would also be an option
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.
It's 400 an json now: e44e6f3
} | ||
|
||
const data = await verifySitePreviewJwt(jwt); | ||
if (!data) { | ||
return res.end("JWT-validation failed."); |
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.
This should probably be 400 bad request
Description
The JWT to invoke the site preview has to be transferred via a GET-Parameter (see Draft Mode in Next.JS). This PR shortens the validity time of this JWT to 10 seconds as the site creates a new JWT (which is not transferred via GET) for itself which stores the preview state.
Additional, do not throw a server error when JWT is not valid. This also prevents an error when the preview-state jwt is not valid anymore, it just will be ignored.
Changeset