I get this error for my embedded app when I switch between stores. When I logout and log back in the app works for the first shop, but when I switch to a different store this error pops up and doesn’t go away until I log out or clear the cookies. Also when loading the app in Safari it shows the same error:
Refused to frame 'https://myshop.myshopify.com/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'".
I’m using Django on the backend and setting the frame ancestor CSP header in the middleware:
class CspMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
frame_ancestors = 'https://admin.shopify.com'
if request.session.get('shopify') and request.session.get('shopify').get('shop_url'):
shop_url = request.session['shopify']['shop_url']
frame_ancestors += f' https://{shop_url}'
response['Content-Security-Policy'] = f"frame-ancestors {frame_ancestors}"
return response
From looking at the logs the CSP headers seem to be all there and correct. It might be that there is an App Bridge client side redirect needed in the auth process? I’ve followed the directions and tried redirecting to the different auth urls but kept getting an infinite loop that breaks the app eventually.
Hopefully there is someone here that ran into a similar situation and can help out.