App reviews, troubleshooting, and recommendations
Hello Every One
i'm developing my shopify App using Laravel and my App keep on recting because of Content security Policy
First i have used the following code in middleware
Hmm, I'm not 100% sure, but you can try updating your middleware code to modify the existing 'Content-Security-Policy' header instead of adding a new one. Here's an example of how you can do this:
$response = $next($request);
$user = Auth::user();
if ($user) {
$csp = $response->headers->get('Content-Security-Policy');
$csp .= "; frame-ancestors https://{$user->name} https://admin.shopify.com";
$response->headers->set('Content-Security-Policy', $csp);
}
return $response;
The above should first retrieve the existing 'Content-Security-Policy' header value using $response->headers->get('Content-Security-Policy')
. Then, it appends the required 'frame-ancestors' directive to the existing value. Finally, it sets the modified 'Content-Security-Policy' header back to the response using $response->headers->set('Content-Security-Policy', $csp)
.
This approach should prevent duplicate 'Content-Security-Policy' headers and apply the necessary 'frame-ancestors' directive to your app.
I hope this helps!
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023