App reviews, troubleshooting, and recommendations
I am creating a new app using PHP (Symfony) and React, taking inspiration from the Laravel APP located at https://github.com/Shopify/shopify-app-template-php. However, I am facing a specific issue and do not have any idea what the problem might be.
When I click on the URL in the console after calling npm run dev
, everything works great and I am redirected to the Shopify Charge Confirmation page. However, the problem occurs when I open the app in the Admin panel, and the current installation does not have an active charge. Then I notice a strange behavior:
I don't have any idea how to fix this issue.
Solved! Go to the solution
This is an accepted solution.
The issue you're experiencing is related to Shopify's Content Security Policy (CSP). When you try to load the charge confirmation page within the Shopify admin panel, it's being blocked due to the CSP restrictions.
To fix this issue, you should handle the billing process in a way that it opens in a new window or a full-page redirect, rather than within the embedded app frame.
When the app is loaded and you detect that there's no active charge, send a message from the app frontend (React) to the backend (PHP Symfony) to initiate the billing process.
In your PHP Symfony backend, create a route that handles the billing process. This route should redirect the user to the charge confirmation page with a full-page redirect, instead of returning a 302 redirect.
In your React frontend, listen for the response from the backend and use the `window.top.location.href` property to perform the full-page redirect. This will open the charge confirmation page in the parent window, bypassing the CSP restrictions.
// Receive the response from your backend containing the charge confirmation URL
const chargeConfirmationUrl = response.data.url;
// Perform the full-page redirect
window.top.location.href = chargeConfirmationUrl;
You can avoid the CSP issue with this approach and allow users to see the charge confirmation page without any errors.
This is an accepted solution.
The issue you're experiencing is related to Shopify's Content Security Policy (CSP). When you try to load the charge confirmation page within the Shopify admin panel, it's being blocked due to the CSP restrictions.
To fix this issue, you should handle the billing process in a way that it opens in a new window or a full-page redirect, rather than within the embedded app frame.
When the app is loaded and you detect that there's no active charge, send a message from the app frontend (React) to the backend (PHP Symfony) to initiate the billing process.
In your PHP Symfony backend, create a route that handles the billing process. This route should redirect the user to the charge confirmation page with a full-page redirect, instead of returning a 302 redirect.
In your React frontend, listen for the response from the backend and use the `window.top.location.href` property to perform the full-page redirect. This will open the charge confirmation page in the parent window, bypassing the CSP restrictions.
// Receive the response from your backend containing the charge confirmation URL
const chargeConfirmationUrl = response.data.url;
// Perform the full-page redirect
window.top.location.href = chargeConfirmationUrl;
You can avoid the CSP issue with this approach and allow users to see the charge confirmation page without any errors.
thanks for you help.
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023