-
Notifications
You must be signed in to change notification settings - Fork 235
fix: Accessing share link redirects to login page #10548
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
fix: Accessing share link redirects to login page #10548
Conversation
|
|
||
| // call superjson custom register | ||
| registerPageToShowRevisionWithMeta(); | ||
| registerShareLinkRelatedPage(); |
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.
問題2 (スコープ外)
shared page にアクセスしようとするとエラーになる
エラー
Server Error
Error: Error serializing `.page` returned from `getServerSideProps` in "/share/[[...path]]".
Reason: `object` ("[object Object]") cannot be serialized as JSON. Please only return JSON serializable data types.
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
isSerializable
webpack:/dist/esm/lib/is-serializable-props.js
every
webpack:/dist/esm/lib/is-serializable-props.js
Array.every
<anonymous>
r
webpack:/dist/esm/lib/is-serializable-props.js
isSerializableProps
webpack:/dist/esm/lib/is-serializable-props.js
e8
webpack:/dist/esm/server/render.js
async doRender
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (2315:20)
async cacheEntry.responseCache.get.routeKind
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (2569:24)
async DevServer.renderToResponseWithComponentsImpl
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (2432:24)
async DevServer.renderPageComponent
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (3016:16)
async DevServer.renderToResponseImpl
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (3078:24)
async DevServer.pipeImpl
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (1537:21)
async DevServer.NextNodeServer.handleCatchallRenderRequest
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/next-server.ts (1020:7)
async DevServer.handleRequestImpl
file:///workspace/growi/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-_5d5e9ca1ee36dcc657c303d88c1f04ef/node_modules/next/src/server/base-server.ts (1318:9)原因
getServerSideProps で呼んでいる シリアライザーが通常ページ用の者だったことが原因
修正方法
旧実装 (master) を参考に shared page 用のシリアライザーを新設
参考
growi/apps/app/src/pages/share/[[...path]].page.tsx
Lines 78 to 91 in c963b15
| superjson.registerCustom<IShareLinkRelatedPage, string>( | |
| { | |
| isApplicable: (v): v is IShareLinkRelatedPage => { | |
| return v != null && v.toObject != null; | |
| }, | |
| serialize: (v) => { | |
| return superjson.stringify(v.toObject()); | |
| }, | |
| deserialize: (v) => { | |
| return superjson.parse(v); | |
| }, | |
| }, | |
| 'IShareLinkRelatedPageTransformer', | |
| ); |
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.
page-data-props.ts で返す page を通常ページにあわせて pageWithMeta にしたら専用 serializer 不要になるんじゃないかな
pageService.findPageAndMetaDataByViewer は、第4引数が isSharedPage?: boolean
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.
共通の serializer を利用するように修正しました
|
|
||
| // call superjson custom register | ||
| registerPageToShowRevisionWithMeta(); | ||
| registerShareLinkRelatedPage(); |
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.
page-data-props.ts で返す page を通常ページにあわせて pageWithMeta にしたら専用 serializer 不要になるんじゃないかな
pageService.findPageAndMetaDataByViewer は、第4引数が isSharedPage?: boolean
| isExpired: undefined, | ||
| shareLink: undefined, | ||
| }, | ||
| }; |
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.
notFound 時の戻り値を共通化
| // expired | ||
| if (shareLink.isExpired()) { | ||
| const populatedPage = | ||
| await pageWithMeta.data.populateDataToShowRevision(true); //shouldExcludeBody = false, |
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.
exipired 時は revisionBody 以外を populate して返却
|
|
||
| // call superjson custom register | ||
| registerPageToShowRevisionWithMeta(); | ||
| registerShareLinkRelatedPage(); |
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.
共通の serializer を利用するように修正しました
Task
https://redmine.weseek.co.jp/issues/174433