Skip to content

Conversation

@imranolas
Copy link
Contributor

The removed code was attempting to detect whether the current page was loaded in an iframe. However, CSP headers with frame-ancestors or similar directives prevent access to window.parent which causes the bridge to fail silently. Removing this check allows the bridge to load successfully regardless of CSP restrictions and while maintaining its core functionality.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the iframe detection logic in the bridge loader to avoid silent failures when CSP frame-ancestors restrictions block access to window.parent.

  • Eliminates the window.parent comparison and warning, allowing the bridge to load under strict CSP.
  • Simplifies storyblokRegisterEvent by always queuing callbacks when not yet loaded.
Comments suppressed due to low confidence (2)

packages/js/src/bridge.ts:12

  • [nitpick] Update the function comment or external documentation to note that iframe checks have been removed and the bridge now loads under all CSP restrictions.
    window.storyblokRegisterEvent = (cb: () => void) => {

packages/js/src/bridge.ts:13

  • Add a test covering the case where window.parent access would throw (e.g., strict CSP), ensuring storyblokRegisterEvent still registers callbacks as expected.
      if (!loaded) {

@imranolas imranolas force-pushed the main branch 2 times, most recently from b0e95f4 to 7770869 Compare July 3, 2025 14:41
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 3, 2025

Open in StackBlitz

@storyblok/astro

npm i https://pkg.pr.new/@storyblok/astro@168

storyblok

npm i https://pkg.pr.new/storyblok@168

@storyblok/eslint-config

npm i https://pkg.pr.new/@storyblok/eslint-config@168

@storyblok/js

npm i https://pkg.pr.new/@storyblok/js@168

storyblok-js-client

npm i https://pkg.pr.new/storyblok-js-client@168

@storyblok/nuxt

npm i https://pkg.pr.new/@storyblok/nuxt@168

@storyblok/react

npm i https://pkg.pr.new/@storyblok/react@168

@storyblok/richtext

npm i https://pkg.pr.new/@storyblok/richtext@168

@storyblok/svelte

npm i https://pkg.pr.new/@storyblok/svelte@168

@storyblok/vue

npm i https://pkg.pr.new/@storyblok/vue@168

commit: 87449df

@imranolas imranolas merged commit 4263254 into main Jul 4, 2025
4 checks passed
@imranolas imranolas deleted the fix/csp-iframe branch July 4, 2025 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants