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! đ