CORS Preflight error in Strapi Headless CMS

Depending on your case, your issue might be as simple as a misconfigured Apache web server. The problem is I wasn’t able to access the Admin Dashboard after rebuilding the code. I rebuilt the app many time, deleted “node_modules”, “build”, and “.cache”. I used different browsers, plugins, extensions, you name it! Nothing worked.

Because I was using the Bitnami image on AWS LightSail for Nodejs, the config file is located under the following path (/opt/bitnami/apache2/conf/vhosts/xxxx-https-vhost.com) where “xxxx” is going to be the name of the application you chose.

Basically, the issue was on the way the server was configured to handle www vs. non-www. The web server was initially configured to redirect all non-www to www. With the way it was set up, it would be blocked by CORS unless allowed in the frontend side. The solution was in redirecting www to non-www as the following:

RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

If you need to do the opposite (redirecting non-www to www), you can use the following:

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Once you’re done, save and close, check the syntax of the edits you made and finally restart the server:

apachectl -t
sudo /opt/bitnami/ctlscript.sh restart

Now, you can run (yarn development) to test your changes. So, next time you see the CORS block and Chrome preflight error, make sure you read the error message well! 🙂

Joomla admin panel shows white blank page after login

Joomla “unintentionally” (I guess) decided to break the Joomla admin panel if you’re running an outdated version reached end of support date. Sorry to disappoint you, but sometimes migration takes time!

If you are running an old version of Joomla with on PHP 7.2 or less, you should’ve started seeing this since November 30, 2020. If you try try to login to the Admin Panel, after you enter your credentials, you’ll get a blank page with no indication of what’s going on. Your first thought would be, have I been pawned! Your next action will be to check your homepage which will be fine.

It turns out that Joomla has set a version check whenever before it loads the Admin Panel components to show you a warning message. That’s all good but the crooks of the matter is if the End of Support (eos) date is reached, it’ll fail to load other components, rendering your Admin panel not loaded. The intention is good to warn you on sunsetting PHP 7.2, but not that great!

Anyway, to fix the issue, change the eos date (line 134) to 2021 🙃🤭

The path of the file should be: public_html/plugins/quickicon/phpversioncheck/phpversioncheck.php

That should fix the issue and you should consider seriously migrating to a newer version or a different platform asap.

If you’re wondering how to find this type of issues, here is what you need to do:

  • If you have shared hosting, create a file and name it php.ini, the add these 2 lines:
    • display_errors = On
    • error_reporting = E_All & ~E_NOTICE & ~E_STRICT
  • edit the index.php in the main folder for the site (in my case it was under public_html/index.php) and add this line in line 2 after the opening of <?php
    • ini_set(‘display_errors’, TRUE); error_reporting(E_ALL);
  • Edit configuration.php in the home directory to set error reporting to development mode
    • Change $error_reporting from ‘none’ to ‘development’
  • Now last step is, try to login and repeat the actions to trigger the logging
  • Then, go check the log file under public_html/Administrator/error_log
    • Review carefully based on timestamp and you should find what causes the issue 🙂

Don’t forget to reverse the actions you performed above (comment out what you added, change development to none, comment out the parts you added to the php.ini).

Good luck!

Can’t download mingw32 on Kali 4.17

Mingw is a cross-compiler to compile windows-oriented exploit code into a windows PE executable within the Linux environment. Unfortunately, current version of Kali installed on my VM is 4.17 can’t find mingw32 when I try to download it with (apt-get install mingw32). It returns (E: Unable to locate package mingw32).

Solution: 

  1. Run this command to edit the sources.list (nano /etc/apt/sources.list)
  2. Comment out any repositories by adding # at the beginning of the line
  3.  Add these 2 repositories and save the file:

deb http://old.kali.org/kali sana main non-free contrib
deb-src http://old.kali.org/kali sana main non-free contrib

4. Run the following command (apt-get clean && apt-get update)

Now, you should be able to run (apt-get install mingw32). After you’re done, you should comment out the repositories you added and uncomment the ones you commented out earlier. Then run (apt-get clean && apt-get update).

JomSocial .. Class only available on Joomla 1.6

On the old JomSocial forum, there was a post that has an attached file that no one was able to download since the team moved to a new forum (jomsocialrt). The post reported an issue with the following actions:

1. After upgrade to Joomla 3.8, when a user tries to edit profile or account details at frontend, an error page gives the message “Class only available on Joomla 1.6”
2. When SuperUser tries to edit user profile at the Jomscoial dashboard, the same error shows up with the message “Class only available on Joomla 1.6”

SOLUTION:

Download the file below and replace it with the one in this path: components/com_community/libraries/jform.php

File to Download: http://files2share.xyz/af0d4c55b0c3dfc4

NOTE: Please remember it’s always a good practice to rename the old file instead of deleting or replacing it before testing. You can rename the old file to (jform.php.OLD). Notice that we added (.OLD) to the end of the file name. Now, if the new file turns to be corrupt or doesn’t solve the issue, we can remove it and rename the old file back to (jform.php).

Solved: The flashing screen on Lenovo Yoga 2 Pro

The Yoga 2 Pro from Lenovo (Model# 20266) has a known issue with constant flashing that doesn’t stop unless you close the lid or shut down the system. The flashing didn’t start until I upgraded from 8.1 to Windows 10 (Home & Pro).

Well, after intense research for over 2 years, I’ve finally figured it out. Here are the magic steps:

  • Run the Intel HD Graphics utility (GfxUIEx.exe) as an Administrator (or it will crash). You can do this by either one of the following:
    • From the Windows menu (Press the Windows logo on your keyboard and type “GfxUIEx.exe”. Then right click to Run As Administrator.
    • From CMD.exe, run this command (runas /user:Administrator GfxUIEx.exe). Then you will have to enter the admin’s password.
  •  

    After you open the Intel HD Graphics Utility, do the following:

    • Click on Display -> Change the Refresh Rate to 48p Hz -> Click APPLY
    • Click on Power -> On Battery -> disable the “Panel Self-Refresh” option -> Click APPLY

 

Updating the BIOS, and all other drivers updates didn’t really make a difference. All you have to do is apply the steps above and your problem should be solved. Next time you wanna buy a device, make sure you buy reliable hardware 🙂