How to enable CORS for your website?

Cross-Origin Resource Sharing (CORS) essentially allows a third-party domain to access your website’s resources. In order to build an app with AppMySite, you’re required to ensure that your web hosting environment supports CORS. 

There are two ways you can enable CORS for your website:

1. Ask your website host

The easiest way to enable CORS is to speak to your website host directly. If you’re new to site management, it may seem tedious to manually enable CORS on your website. In this case, it’s best to get in touch with a technical support representative and ask them to enable CORS for your website. 

2. Edit your website’s .htaccess file

You can also enable CORS by directly updating your website’s htaccess file. 

A .htaccess file basically configures your website’s subfolders and subdirectories. Generally, your website host would be able to provide documentation on how to enable CORS via htaccess. You should ask your website host before making any changes yourself. 

Here’s how you can enable CORS via htaccess:

  • Login to your website’s cPanel and open the File Manager. Alternatively, you can also access your website server via FTP. 
  • Open the .htaccess file. This should be visible in the public HTML directory. 
  • Add the following line to the file: 
Header set Access-Control-Allow-Origin "*"
  • This may or may not work based on your server platform. You can visit this resource to learn how to enable CORS for your website. 

Related Articles