Arcadier / Developer-Community-Support

:revolving_hearts: Share new ideas with us and report bugs/problems here
4 stars 1 forks source link

Issue with plugin on staging environment #31

Open Arcadier-Support opened 3 years ago

Arcadier-Support commented 3 years ago

Currently we are presenting issues related with the plugin which you uploaded to the Shield Medical staging server (https://pharmasynch.staging.arcadier.io/admin/dashboard).

An error it’s displayed when we want to access to a PHP page of our plugin from the seller dashboard: image001

As we know the error displayed it’s an error related when an html page/php file is not found, but in the browser console it show the status code = 200, maybe you guys could provide more feedback about this error, also, we can confirm that the file/page where the error is presented and we want to access (coupon_page.php) it’s stored on the zip file we provided to the Arcadier team as well we downloaded that zip file and installed it to our sandbox page and it works perfectly, as you can see in the following image: image002

I hope you can provide some feedback about this issue, thanks in advance.

tanoojoy commented 3 years ago

Can you check if there are any hardcoded IDs/GUIDs in your plugin? That could be the reason why it works in one environment and not the other.

A typical example is having hardcoded the plugin ID which can cause the above issue.

To solve this, you can use the following solutions: Javascript:

(function() {
    var scriptSrc = document.currentScript.src;
    var packagePath = scriptSrc.replace('/scripts/scripts.js', '').trim();
    var re = /([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})/i;
    var plugin_id = re.exec(scriptSrc.toLowerCase())[1];

   //rest of your plugin
})();

PHP:

$serverPath = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
$url =   explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$packageURL=$serverPath . '://'.$url[1] . '/'.$url[4].'/'.$url[2].'/'.$url[3];