Fix access to cookies when used in iframe (#202)

* Fix access to cookies when used in iframe

* Allow https: embed
This commit is contained in:
Samy Pessé
2024-02-29 11:24:55 +01:00
committed by GitHub
parent 826ddbc533
commit cb91fb9df8
2 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ export function getContentSecurityPolicy(scripts: SpaceIntegrationScript[], nonc
object-src 'none';
base-uri 'self' ${assetsDomain};
form-action 'self' ${assetsDomain};
frame-ancestors 'none';
frame-ancestors https:;
`;
const result = scripts
+12 -8
View File
@@ -53,17 +53,19 @@ type URLLookupMode =
*/
| 'multi-id';
export type LookupCookies = Record<
string,
{
value: string;
options?: Partial<ResponseCookie>;
}
>;
export type LookupResult = PublishedContentWithCache & {
/** API endpoint to use for the content post lookup */
apiEndpoint?: string;
/** Cookies to store on the response */
cookies?: Record<
string,
{
value: string;
options?: Partial<ResponseCookie>;
}
>;
cookies?: LookupCookies;
};
/**
@@ -377,12 +379,14 @@ async function lookupSpaceInMultiIdMode(request: NextRequest, url: URL): Promise
() => getSpace.revalidate(spaceId),
);
const cookies = {
const cookies: LookupCookies = {
[cookieName]: {
value: encodeGitBookTokenCookie(spaceId, apiToken, apiEndpoint),
options: {
httpOnly: true,
maxAge: 60 * 30,
secure: process.env.NODE_ENV === 'production',
sameSite: 'none',
},
},
};