feat: allow embed share view into iframe (#257)

This commit is contained in:
tea artist 2023-11-17 18:17:27 +08:00 committed by GitHub
parent 44023b56c7
commit 265a468d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,3 @@
tasks: tasks:
- init: yarn install - init: pnpm install
command: yarn workspace nextjs-app run dev -p 3000 command: make sqlite-mode && cd apps/nestjs-backend && pnpm dev

View File

@ -138,7 +138,6 @@ export class ShareDbPermissionService {
// view share permission validation // view share permission validation
const shareId = context.agent.custom.shareId; const shareId = context.agent.custom.shareId;
if (shareId && isShareViewResourceDoc(docType as IdPrefix)) { if (shareId && isShareViewResourceDoc(docType as IdPrefix)) {
console.log('context.snapshots === ', context.snapshots);
const error = await this.checkReadViewSharePermission( const error = await this.checkReadViewSharePermission(
shareId, shareId,
context.collection, context.collection,

View File

@ -5,10 +5,14 @@ import { ssrApi } from '@/backend/api/rest/table.ssr';
import type { IShareViewPageProps } from '@/features/app/blocks/share/view/ShareViewPage'; import type { IShareViewPageProps } from '@/features/app/blocks/share/view/ShareViewPage';
import { ShareViewPage } from '@/features/app/blocks/share/view/ShareViewPage'; import { ShareViewPage } from '@/features/app/blocks/share/view/ShareViewPage';
export const getServerSideProps: GetServerSideProps<IShareViewPageProps> = async (context) => { export const getServerSideProps: GetServerSideProps<IShareViewPageProps> = async ({
const { shareId } = context.query; res,
const req = context.req; req,
query,
}) => {
const { shareId } = query;
try { try {
res.setHeader('Content-Security-Policy', "frame-ancestors 'self' *;");
ssrApi.axios.defaults.headers['cookie'] = req.headers.cookie || ''; ssrApi.axios.defaults.headers['cookie'] = req.headers.cookie || '';
const shareViewData = await ssrApi.getShareView(shareId as string); const shareViewData = await ssrApi.getShareView(shareId as string);
return { return {